Commits

rmtew committed a33beef Draft

Skip threading related unit test logic, if no threading compiled into Python.

Comments (0)

Files changed (2)

Stackless/unittests/support.py

 import stackless
-import threading
+try:
+    import threading
+    withThreads = True
+except:
+    withThreads = False
 import unittest
 
 class StacklessTestCase(unittest.TestCase):
     def setUp(self):
         self.assertEqual(stackless.getruncount(), 1, "Leakage from other tests, with %d tasklets still in the scheduler" % (stackless.getruncount() - 1))        
-        self.assertEqual(threading.activeCount(), 1, "Leakage from other threads, with %d threads running (1 expected)" % (threading.activeCount()))
+        if withThreads:
+            self.assertEqual(threading.activeCount(), 1, "Leakage from other threads, with %d threads running (1 expected)" % (threading.activeCount()))
 
     def tearDown(self):
         # Tasklets created in pickling tests can be left in the scheduler when they finish.  We can feel free to
             current.kill()
             current = next
         self.assertEqual(stackless.getruncount(), 1, "Leakage from this test, with %d tasklets still in the scheduler" % (stackless.getruncount() - 1))
-        if threading.activeCount() > 1:
+        if withThreads and threading.activeCount() > 1:
             activeThreads = threading.enumerate()
             activeThreads.remove(threading.currentThread())
             if activeThreads:

Stackless/unittests/test_channel.py

 import unittest
 import stackless
-import threading
+try:
+    import threading
+    withThreads = True
+except ImportError:
+    withThreads = False
 import sys
 import traceback
 from support import StacklessTestCase
         c = stackless.channel()
         self.assertRaises(RuntimeError, c.receive)
 
+    @unittest.skipUnless(withThreads, "Compiled without threading")
     def testInterthreadCommunication(self):
         ''' Test that tasklets in different threads sending over channels to each other work. '''    
         self.assertEqual(stackless.getruncount(), 1, "Leakage from other tests, with tasklets still in the scheduler.")