Skip to content

Instantly share code, notes, and snippets.

@schmir
Created March 15, 2012 14:47
Show Gist options
  • Save schmir/2044570 to your computer and use it in GitHub Desktop.
Save schmir/2044570 to your computer and use it in GitHub Desktop.
import threading
def pytest_runtest_setup(item):
item.activeCount = threading.activeCount()
item.session._setupstate.prepare(item)
def pytest_runtest_teardown(item, nextitem):
item.session._setupstate.teardown_exact(item, nextitem)
after = threading.activeCount()
before = item.activeCount
assert after == before, "number of threads changed from %s to %s" % (before, after)
# def pytest_runtest_call(item):
# before = threading.activeCount()
# item.runtest()
# after = threading.activeCount()
# assert after == before, "activeCount changed"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment