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