|
|
|
@ -282,11 +282,10 @@ class TestCase(unittest2.TestCase):
|
|
|
|
|
'mitogen.master.join_thread_async'
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def _teardown_check_threads(cls):
|
|
|
|
|
def _teardown_check_threads(self):
|
|
|
|
|
counts = {}
|
|
|
|
|
for thread in threading.enumerate():
|
|
|
|
|
assert thread.name in cls.ALLOWED_THREADS, \
|
|
|
|
|
assert thread.name in self.ALLOWED_THREADS, \
|
|
|
|
|
'Found thread %r still running after tests.' % (thread.name,)
|
|
|
|
|
counts[thread.name] = counts.get(thread.name, 0) + 1
|
|
|
|
|
|
|
|
|
@ -294,20 +293,18 @@ class TestCase(unittest2.TestCase):
|
|
|
|
|
assert counts[name] == 1, \
|
|
|
|
|
'Found %d copies of thread %r running after tests.' % (name,)
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def _teardown_check_fds(cls):
|
|
|
|
|
def _teardown_check_fds(self):
|
|
|
|
|
mitogen.core.Latch._on_fork()
|
|
|
|
|
if get_fd_count() != cls._fd_count_before:
|
|
|
|
|
if get_fd_count() != self._fd_count_before:
|
|
|
|
|
import os; os.system('lsof -p %s' % (os.getpid(),))
|
|
|
|
|
assert 0, "%s leaked FDs. Count before: %s, after: %s" % (
|
|
|
|
|
cls, cls._fd_count_before, get_fd_count(),
|
|
|
|
|
self, self._fd_count_before, get_fd_count(),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def tearDownClass(cls):
|
|
|
|
|
super(TestCase, cls).tearDownClass()
|
|
|
|
|
cls._teardown_check_threads()
|
|
|
|
|
cls._teardown_check_fds()
|
|
|
|
|
def tearDown(self):
|
|
|
|
|
self._teardown_check_threads()
|
|
|
|
|
self._teardown_check_fds()
|
|
|
|
|
super(TestCase, self).tearDown()
|
|
|
|
|
|
|
|
|
|
def assertRaises(self, exc, func, *args, **kwargs):
|
|
|
|
|
"""Like regular assertRaises, except return the exception that was
|
|
|
|
|