diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-04-27 23:01:29 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-04-27 23:01:29 (GMT) |
commit | be595d336c6e3cdd899e9c031e86bf6dab850c07 (patch) | |
tree | af638d1e95d7488eea6543dd7fa1810de1d656de /Lib | |
parent | fd8ea99275cd5fcc3dc97a1d629b873caecd93f4 (diff) | |
download | cpython-be595d336c6e3cdd899e9c031e86bf6dab850c07.zip cpython-be595d336c6e3cdd899e9c031e86bf6dab850c07.tar.gz cpython-be595d336c6e3cdd899e9c031e86bf6dab850c07.tar.bz2 |
Issue #7449, part 7: simplify threading detection in test_capi
* Skip TestPendingCalls if threading module is missing
* Test if threading module is present or not, instead of test the presence of
_testcapi._test_thread_state
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_capi.py | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py index c313dcf..7c25923 100644 --- a/Lib/test/test_capi.py +++ b/Lib/test/test_capi.py @@ -6,10 +6,14 @@ import sys import time import random import unittest -import threading from test import test_support +try: + import threading +except ImportError: + threading = None import _testcapi +@unittest.skipUnless(threading, 'Threading required for this test.') class TestPendingCalls(unittest.TestCase): def pendingcalls_submit(self, l, n): @@ -47,7 +51,6 @@ class TestPendingCalls(unittest.TestCase): print "(%i)"%(len(l),) def test_pendingcalls_threaded(self): - #do every callback on a separate thread n = 32 #total callbacks threads = [] @@ -123,17 +126,10 @@ def test_main(): raise test_support.TestFailed, \ "Couldn't find main thread correctly in the list" - try: - _testcapi._test_thread_state - have_thread_state = True - except AttributeError: - have_thread_state = False - - if have_thread_state: + if threading: import thread import time TestThreadState() - import threading t=threading.Thread(target=TestThreadState) t.start() t.join() |