Suppress transient refleaks in test_threading.

This commit is contained in:
Antoine Pitrou 2009-10-27 20:02:23 +00:00
parent a763c06357
commit bb0bb30acc
1 changed files with 12 additions and 3 deletions

View File

@ -54,7 +54,16 @@ def run(self):
print '%s is finished. %d tasks are running' % (
self.name, self.nrunning.get())
class ThreadTests(unittest.TestCase):
class BaseTestCase(unittest.TestCase):
def setUp(self):
self._threads = test.test_support.threading_setup()
def tearDown(self):
test.test_support.threading_cleanup(*self._threads)
test.test_support.reap_children()
class ThreadTests(BaseTestCase):
# Create a bunch of threads, let each do some work, wait until all are
# done.
@ -382,7 +391,7 @@ def _run(self, other_ref, yet_another):
sys.getrefcount(weak_raising_cyclic_object())))
class ThreadJoinOnShutdown(unittest.TestCase):
class ThreadJoinOnShutdown(BaseTestCase):
def _run_and_join(self, script):
script = """if 1:
@ -465,7 +474,7 @@ def worker():
self._run_and_join(script)
class ThreadingExceptionTests(unittest.TestCase):
class ThreadingExceptionTests(BaseTestCase):
# A RuntimeError should be raised if Thread.start() is called
# multiple times.
def test_start_thread_again(self):