summaryrefslogtreecommitdiff
path: root/tests/test_arcs.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-06-04 12:13:16 -0400
committerNed Batchelder <ned@nedbatchelder.com>2021-06-05 13:56:25 -0400
commit69e9a61f28853e2e79f9711b97b7ce4f57e834ed (patch)
treed7e5862aff7e6d35ce13dd527c5909365dc6451b /tests/test_arcs.py
parent1a5cd1aa1e4852fd01848e1187224c3d6160bf6b (diff)
downloadpython-coveragepy-git-69e9a61f28853e2e79f9711b97b7ce4f57e834ed.tar.gz
test: add a test for annotated assignment
Every statement-level ast node should be tested. Annotated assignment was missing. Also, we don't need "exec" anymore, that was only for Python 2. And: this is the 1000th test!
Diffstat (limited to 'tests/test_arcs.py')
-rw-r--r--tests/test_arcs.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/test_arcs.py b/tests/test_arcs.py
index 8bf83008..905430e6 100644
--- a/tests/test_arcs.py
+++ b/tests/test_arcs.py
@@ -1659,6 +1659,21 @@ class AsyncTest(CoverageTest):
)
+class AnnotationTest(CoverageTest):
+ """Tests using type annotations."""
+
+ def test_annotations(self):
+ self.check_coverage("""\
+ def f(x:str, y:int) -> str:
+ a:int = 2
+ return f"{x}, {y}, {a}, 3"
+ print(f("x", 4))
+ """,
+ arcz=".1 .2 23 3. 14 4.",
+ )
+ assert self.stdout() == "x, 4, 2, 3\n"
+
+
class ExcludeTest(CoverageTest):
"""Tests of exclusions to indicate known partial branches."""