summaryrefslogtreecommitdiff
path: root/tests/test_arcs.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2015-04-20 14:33:15 -0400
committerNed Batchelder <ned@nedbatchelder.com>2015-04-20 14:33:15 -0400
commit0652f558bd07f82bcdca3843c00824b8964289fd (patch)
tree0b347de985dfd85c970d8c21b69fb7cb5d2d406f /tests/test_arcs.py
parente63fc1d6c7ab1f42fd23b21fc9672f96b5ba5dcc (diff)
downloadpython-coveragepy-0652f558bd07f82bcdca3843c00824b8964289fd.tar.gz
Add a test with bidirectional generators
Diffstat (limited to 'tests/test_arcs.py')
-rw-r--r--tests/test_arcs.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test_arcs.py b/tests/test_arcs.py
index 2b7dafd..a4462ea 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."""