1 # Run the _testcapi module tests (tests for the Python/C API): by defn,
2 # these are all functions _testcapi exports whose name begins with 'test_'.
5 from test
import test_support
8 for name
in dir(_testcapi
):
9 if name
.startswith('test_'):
10 test
= getattr(_testcapi
, name
)
11 if test_support
.verbose
:
12 print "internal", name
15 except _testcapi
.error
:
16 raise test_support
.TestFailed
, sys
.exc_info()[1]
18 # some extra thread-state tests driven via _testcapi
19 def TestThreadState():
23 if test_support
.verbose
:
24 print "auto-thread-state"
29 idents
.append(thread
.get_ident())
31 _testcapi
._test
_thread
_state
(callback
)
33 # Check our main thread is in the list exactly 3 times.
34 if idents
.count(thread
.get_ident()) != 3:
35 raise test_support
.TestFailed
, \
36 "Couldn't find main thread correctly in the list"
39 _testcapi
._test
_thread
_state
40 have_thread_state
= True
41 except AttributeError:
42 have_thread_state
= False
47 t
=threading
.Thread(target
=TestThreadState
)