Skip to content

Commit

Permalink
Fix a few minor issues in the test suite
Browse files Browse the repository at this point in the history
- enable gc-debugging
- fix two uncollectable tasklets
- skip a _H test, that requires soft-switching
  • Loading branch information
Anselm Kruis committed Nov 11, 2016
1 parent a43be75 commit e01bb16
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Stackless/unittests/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
import inspect
from io import StringIO
import contextlib
import gc

# emit warnings about uncollectable objects
gc.set_debug(gc.DEBUG_UNCOLLECTABLE)
try:
long
except NameError:
Expand Down Expand Up @@ -273,6 +276,7 @@ def tearDown(self):
activeThreads.pop().join(0.5)
active_count = threading.active_count()
self.assertEqual(active_count, expected_thread_count, "Leakage from other threads, with %d threads running (%d expected)" % (active_count, expected_thread_count))
gc.collect() # emits warnings about uncollectable objects after each test

# limited pickling support for test cases
# Between setUp() and tearDown() the test-case has a
Expand Down
6 changes: 4 additions & 2 deletions Stackless/unittests/test_defects.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ def func(self):
stackless.schedule_remove()
self.fail("We shouldn't be here")
stackless.run() # flush all runnables
stackless.tasklet(func)(self)
t = stackless.tasklet(func)(self)
stackless.run()
t.kill() # avoid a resource leak caused by an uncollectable tasklet

@require_one_thread
def testScheduleRemove2(self):
Expand Down Expand Up @@ -383,6 +384,7 @@ def test_tasklet_end_with_wrong_recursion_level(self):
tasklet of other thread ended. To do so, it creates a new temporary main tasklet. The
assertion failure happens during the end of the killed tasklet.
"""
self.skipUnlessSoftswitching()
if True:
def print(*args):
pass
Expand All @@ -401,7 +403,7 @@ def other_thread_main():
print("Other thread paused", self.tlet)
self.tlet.run()
self.assertGreaterEqual(self.tlet.recursion_depth, 2)
self.tlet.bind(lambda: None, ())
self.tlet.bind(lambda: None, ()) # requires soft switching
self.assertEqual(self.tlet.recursion_depth, 0)
# before issue #91 got fixed, the assertion violation occurred here

Expand Down
3 changes: 3 additions & 0 deletions Stackless/unittests/test_watchdog.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,9 @@ def watchdog1():
stackless.run()
self.assertLessEqual([None], self.watchdog_list)
stackless.run()
# avoid a resource leak
for t in tasklets:
t.kill()

def test_schedule_deeper_soft(self):
self._test_schedule_deeper(True)
Expand Down

0 comments on commit e01bb16

Please sign in to comment.