diff options
Diffstat (limited to 'tests/test_coroutine.py')
-rw-r--r-- | tests/test_coroutine.py | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/tests/test_coroutine.py b/tests/test_coroutine.py index 38de7a3d..9ad1f31f 100644 --- a/tests/test_coroutine.py +++ b/tests/test_coroutine.py @@ -2,7 +2,6 @@ import os.path, sys -from nose.plugins.skip import SkipTest import coverage from tests.coveragetest import CoverageTest @@ -32,7 +31,7 @@ def line_count(s): class CoroutineTest(CoverageTest): """Tests of the coroutine support in coverage.py.""" - LIMIT = 3 # Should be 1000, but this gives me a reasonable amount of output. + LIMIT = 1000 # The code common to all the concurrency models. COMMON = """ @@ -96,6 +95,15 @@ class CoroutineTest(CoverageTest): import gevent.queue as queue """ + COMMON + # Uncomplicated code that doesn't use any of the coroutining stuff, to test + # the simple case under each of the regimes. + SIMPLE = """\ + total = 0 + for i in range({LIMIT}): + total += i + print(total) + """.format(LIMIT=LIMIT) + def try_some_code(self, code, args): """Run some coroutine testing code and see that it was all covered.""" @@ -122,35 +130,25 @@ class CoroutineTest(CoverageTest): def test_threads(self): self.try_some_code(self.THREAD, "") - def test_eventlet(self): - if eventlet is None: - raise SkipTest("No eventlet available") - - self.try_some_code(self.EVENTLET, "--coroutine=eventlet") - - def test_gevent(self): - #raise SkipTest("Still not sure why gevent isn't working...") + def test_threads_simple_code(self): + self.try_some_code(self.SIMPLE, "") - if gevent is None: - raise SkipTest("No gevent available") + if eventlet is not None: + def test_eventlet(self): + self.try_some_code(self.EVENTLET, "--coroutine=eventlet") - self.try_some_code(self.GEVENT, "--coroutine=gevent") + def test_eventlet_simple_code(self): + self.try_some_code(self.SIMPLE, "--coroutine=eventlet") - def test_gevent_badly(self): - # This test shouldn't pass. It should fail because we are running - # gevent code without the --coroutine=gevent flag. It's here so I can - # see how gevent code looks when it isn't measured properly. The C - # extension implementation of coroutining is currently acting precisely - # as if no coroutine support is available (demonstrated by this test), - # and I don't know why. This test is part of me debugging that - # problem. - if gevent is None: - raise SkipTest("No gevent available") + if gevent is not None: + def test_gevent(self): + self.try_some_code(self.GEVENT, "--coroutine=gevent") - self.try_some_code(self.GEVENT, "") + def test_gevent_simple_code(self): + self.try_some_code(self.SIMPLE, "--coroutine=gevent") def print_simple_annotation(code, linenos): """Print the lines in `code` with X for each line number in `linenos`.""" for lineno, line in enumerate(code.splitlines(), start=1): - print(" {0:s} {1}".format("X" if lineno in linenos else " ", line)) + print(" {0} {1}".format("X" if lineno in linenos else " ", line)) |