[Python-checkins] r80565 - python/trunk/Lib/test/test_capi.py
victor.stinner
python-checkins at python.org
Wed Apr 28 01:01:30 CEST 2010
Author: victor.stinner
Date: Wed Apr 28 01:01:29 2010
New Revision: 80565
Log:
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
Modified:
python/trunk/Lib/test/test_capi.py
Modified: python/trunk/Lib/test/test_capi.py
==============================================================================
--- python/trunk/Lib/test/test_capi.py (original)
+++ python/trunk/Lib/test/test_capi.py Wed Apr 28 01:01:29 2010
@@ -6,10 +6,14 @@
import time
import random
import unittest
-import threading
from test import test_support
+try:
+ import threading
+except ImportError:
+ threading = None
import _testcapi
+ at unittest.skipUnless(threading, 'Threading required for this test.')
class TestPendingCalls(unittest.TestCase):
def pendingcalls_submit(self, l, n):
@@ -47,7 +51,6 @@
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 @@
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()
More information about the Python-checkins
mailing list