diff options
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/support.py | 11 | ||||
-rw-r--r-- | Lib/test/test_hashlib.py | 3 | ||||
-rw-r--r-- | Lib/test/test_os.py | 4 | ||||
-rw-r--r-- | Lib/test/test_unittest.py | 2 |
4 files changed, 14 insertions, 6 deletions
diff --git a/Lib/test/support.py b/Lib/test/support.py index df114a2..b91d732 100644 --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -5,6 +5,7 @@ if __name__ != 'test.support': import contextlib import errno +import functools import socket import sys import os @@ -933,6 +934,16 @@ def threading_cleanup(num_active, num_limbo): count += 1 time.sleep(0.1) +def reap_threads(func): + @functools.wraps(func) + def decorator(*args): + key = threading_setup() + try: + return func(*args) + finally: + threading_cleanup(*key) + return decorator + def reap_children(): """Use this function at the end of test_main() whenever sub-processes are started. This will help ensure that no extra children (zombies) diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py index 594f5dd..5bfea6b 100644 --- a/Lib/test/test_hashlib.py +++ b/Lib/test/test_hashlib.py @@ -267,10 +267,9 @@ class HashLibTestCase(unittest.TestCase): self.assertEqual(expected_hash, hasher.hexdigest()) - +@support.reap_threads def test_main(): support.run_unittest(HashLibTestCase) - if __name__ == "__main__": test_main() diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index c680d8d..0600cfc 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -35,9 +35,7 @@ class FileTests(unittest.TestCase): retries += 1 if retries > 10: # XXX test skipped - print("couldn't allocate two consecutive fds, " - "skipping test_closerange", file=sys.stderr) - return + self.skipTest("couldn't allocate two consecutive fds") first, second = second, os.dup(second) finally: os.close(second) diff --git a/Lib/test/test_unittest.py b/Lib/test/test_unittest.py index ea33180..858f24b 100644 --- a/Lib/test/test_unittest.py +++ b/Lib/test/test_unittest.py @@ -3175,7 +3175,7 @@ class TestCleanUp(TestCase): result = MockResult() test = TestableTest('testNothing') - test._result = result + test._resultForDoCleanups = result exc1 = Exception('foo') exc2 = Exception('bar') |