55import stackless
66import sys
77import traceback
8- import contextlib
98import weakref
109import types
11- import _thread as thread
10+ import contextlib
1211import time
1312import os
1413from stackless import _test_nostacklesscall as apply
15-
16- from support import StacklessTestCase , AsTaskletTestCase , require_one_thread
1714try :
15+ import _thread as thread
1816 import threading
1917 withThreads = True
2018except :
2119 withThreads = False
2220
21+ from support import StacklessTestCase , AsTaskletTestCase , require_one_thread
22+
2323
2424def is_soft ():
2525 softswitch = stackless .enable_softswitch (0 )
@@ -504,6 +504,7 @@ def task():
504504 self .assertFalse (t .alive )
505505 self .assertEqual (t .thread_id , stackless .current .thread_id )
506506
507+ @unittest .skipUnless (withThreads , "requires thread support" )
507508 @require_one_thread
508509 def test_kill_thread_without_main_tasklet (self ):
509510 # this test depends on a race condition.
@@ -607,15 +608,19 @@ def other_thread_main():
607608 tlet .remove ()
608609 tlet .kill ()
609610
611+ @unittest .skipUnless (withThreads , "requires thread support" )
610612 def test_kill_without_thread_state_nl0 (self ):
611613 return self ._test_kill_without_thread_state (0 , False )
612614
615+ @unittest .skipUnless (withThreads , "requires thread support" )
613616 def test_kill_without_thread_state_nl1 (self ):
614617 return self ._test_kill_without_thread_state (1 , False )
615618
619+ @unittest .skipUnless (withThreads , "requires thread support" )
616620 def test_kill_without_thread_state_blocked_nl0 (self ):
617621 return self ._test_kill_without_thread_state (0 , True )
618622
623+ @unittest .skipUnless (withThreads , "requires thread support" )
619624 def test_kill_without_thread_state_blocked_nl1 (self ):
620625 return self ._test_kill_without_thread_state (1 , True )
621626
@@ -1011,6 +1016,7 @@ def test_bind_args_not_runnable(self):
10111016 self .assertFalse (t .scheduled )
10121017 t .run ()
10131018
1019+ @unittest .skipUnless (withThreads , "requires thread support" )
10141020 def test_unbind_main (self ):
10151021 self .skipUnlessSoftswitching ()
10161022
@@ -1034,6 +1040,7 @@ def other_thread():
10341040 t .join ()
10351041 self .assertTrue (done [0 ])
10361042
1043+ @unittest .skipUnless (withThreads , "requires thread support" )
10371044 def test_rebind_main (self ):
10381045 # rebind the main tasklet of a thread. This is highly discouraged,
10391046 # because it will deadlock, if the thread is a non daemon threading.Thread.
@@ -1086,6 +1093,7 @@ def test():
10861093 self .assertEqual (tlet .recursion_depth , 0 )
10871094 self .assertEqual (self .recursion_depth_in_test , 1 )
10881095
1096+ @unittest .skipUnless (withThreads , "requires thread support" )
10891097 def test_unbind_fail_cstate_no_thread (self ):
10901098 # https://bitbucket.org/stackless-dev/stackless/issues/92
10911099 loop = True
0 commit comments