diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2015-04-20 14:33:15 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2015-04-20 14:33:15 -0400 |
commit | fd311e747c67faa4e61873dcfefd4159b67f977a (patch) | |
tree | 6d941cbb42f8f03d8a5f2cce0e4f9a6685af3c34 | |
parent | 6795a7c8ad052c524d352d371ca402b5c322913d (diff) | |
download | python-coveragepy-git-fd311e747c67faa4e61873dcfefd4159b67f977a.tar.gz |
Add a test with bidirectional generators
-rw-r--r-- | tests/test_arcs.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test_arcs.py b/tests/test_arcs.py index 2b7dafd4..a4462ea1 100644 --- a/tests/test_arcs.py +++ b/tests/test_arcs.py @@ -646,6 +646,27 @@ class YieldTest(CoverageTest): arcz_missing=".3 3-3", arcz_unpredicted="") + def test_coroutines(self): + self.check_coverage("""\ + def double_inputs(): + while [1]: # avoid compiler differences + x = yield + x *= 2 + yield x + + gen = double_inputs() + next(gen) + print(gen.send(10)) + next(gen) + print(gen.send(6)) + """, + arcz= + ".1 17 78 89 9A AB B. " + ".2 23 34 45 52 2.", + arcz_missing="2.", + arcz_unpredicted="") + self.assertEqual(self.stdout(), "20\n12\n") + class MiscArcTest(CoverageTest): """Miscellaneous arc-measuring tests.""" |