diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-04-27 21:46:03 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-04-27 21:46:03 (GMT) |
commit | d9d147b8060970bca0e8ebb4ee4ba210558d5c28 (patch) | |
tree | 7ebae5eedc9c1901762a962c53393f4cb0ddc20e | |
parent | ae9f8bd2f99a0494f945d883bb1fb9d6638c4a24 (diff) | |
download | cpython-d9d147b8060970bca0e8ebb4ee4ba210558d5c28.zip cpython-d9d147b8060970bca0e8ebb4ee4ba210558d5c28.tar.gz cpython-d9d147b8060970bca0e8ebb4ee4ba210558d5c28.tar.bz2 |
Issue #7449, part 1: fix test_support.py for Python compiled without thread
-rw-r--r-- | Lib/test/test_support.py | 22 | ||||
-rw-r--r-- | Misc/NEWS | 2 |
2 files changed, 20 insertions, 4 deletions
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py index d76d569..7dc52bb 100644 --- a/Lib/test/test_support.py +++ b/Lib/test/test_support.py @@ -18,6 +18,10 @@ import importlib import UserDict import re import time +try: + import thread +except ImportError: + thread = None __all__ = ["Error", "TestFailed", "ResourceDenied", "import_module", "verbose", "use_resources", "max_memuse", "record_original_stdout", @@ -44,7 +48,7 @@ class ResourceDenied(unittest.SkipTest): """Test skipped because it requested a disallowed resource. This is raised when a test calls requires() for a resource that - has not be enabled. It is used to distinguish between expected + has not been enabled. It is used to distinguish between expected and unexpected skips. """ @@ -1078,11 +1082,14 @@ def run_doctest(module, verbosity=None): # at the end of a test run. def threading_setup(): - import thread - return thread._count(), + if thread: + return thread._count(), + else: + return 1, def threading_cleanup(nb_threads): - import thread + if not thread: + return _MAX_COUNT = 10 for count in range(_MAX_COUNT): @@ -1093,6 +1100,13 @@ def threading_cleanup(nb_threads): # XXX print a warning in case of failure? def reap_threads(func): + """Use this function when threads are being used. This will + ensure that the threads are cleaned up even when the test fails. + If threading is unavailable this function does nothing. + """ + if not thread: + return func + @functools.wraps(func) def decorator(*args): key = threading_setup() @@ -109,6 +109,8 @@ Extension Modules Tests ----- +- Issue #7449: Fix many tests to support Python compiled without thread support + - Issue #8108: test_ftplib's non-blocking SSL server now has proper handling of SSL shutdowns. |