[Python-checkins] r72655 - in python/trunk/Lib/test: test_hashlib.py test_support.py
benjamin.peterson
python-checkins at python.org
Fri May 15 00:40:34 CEST 2009
Author: benjamin.peterson
Date: Fri May 15 00:40:34 2009
New Revision: 72655
Log:
a useful decorator for cleaning up threads
Modified:
python/trunk/Lib/test/test_hashlib.py
python/trunk/Lib/test/test_support.py
Modified: python/trunk/Lib/test/test_hashlib.py
==============================================================================
--- python/trunk/Lib/test/test_hashlib.py (original)
+++ python/trunk/Lib/test/test_hashlib.py Fri May 15 00:40:34 2009
@@ -254,14 +254,9 @@
self.assertEqual(expected_hash, hasher.hexdigest())
-
+ at test_support.reap_threads
def test_main():
- key = test_support.threading_setup()
- try:
- test_support.run_unittest(HashLibTestCase)
- finally:
- test_support.threading_cleanup(*key)
-
+ test_support.run_unittest(HashLibTestCase)
if __name__ == "__main__":
test_main()
Modified: python/trunk/Lib/test/test_support.py
==============================================================================
--- python/trunk/Lib/test/test_support.py (original)
+++ python/trunk/Lib/test/test_support.py Fri May 15 00:40:34 2009
@@ -5,6 +5,7 @@
import contextlib
import errno
+import functools
import socket
import sys
import os
@@ -934,6 +935,16 @@
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)
More information about the Python-checkins
mailing list