summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-07-19 07:51:03 -0400
committerNed Batchelder <ned@nedbatchelder.com>2021-07-19 08:04:55 -0400
commit1f620f8581a6661a9b5ec78beaf77ae5a8ebf41c (patch)
tree29859e43dee2d4885b0a3c8b64419581264973df
parent9871209bcfae721c43a45ebccd15a469c013abd5 (diff)
downloadpython-coveragepy-git-1f620f8581a6661a9b5ec78beaf77ae5a8ebf41c.tar.gz
test: add tests of #1175
Python versions before 3.10 didn't trace trailing "pass" statements correctly. I don't think that will change at this point, so we'll skip this test for those versions.
-rw-r--r--tests/test_arcs.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/test_arcs.py b/tests/test_arcs.py
index 2696322f..ed6c16e4 100644
--- a/tests/test_arcs.py
+++ b/tests/test_arcs.py
@@ -517,6 +517,40 @@ class LoopArcTest(CoverageTest):
arcz=".1 12 -22 2-2 23 34 42 2.",
)
+ # https://bugs.python.org/issue44672
+ @pytest.mark.skipif(env.PYVERSION < (3, 10), reason="<3.10 traced final pass incorrectly")
+ def test_incorrect_loop_exit_bug_1175(self):
+ self.check_coverage("""\
+ def wrong_loop(x):
+ if x:
+ for i in [3, 33]:
+ print(i+4)
+ else:
+ pass
+
+ wrong_loop(8)
+ """,
+ arcz=".1 .2 23 26 34 43 3. 6. 18 8.",
+ arcz_missing="26 6.",
+ )
+
+ # https://bugs.python.org/issue44672
+ @pytest.mark.skipif(env.PYVERSION < (3, 10), reason="<3.10 traced final pass incorrectly")
+ def test_incorrect_if_bug_1175(self):
+ self.check_coverage("""\
+ def wrong_loop(x):
+ if x:
+ if x:
+ print(4)
+ else:
+ pass
+
+ wrong_loop(8)
+ """,
+ arcz=".1 .2 23 26 34 4. 3. 6. 18 8.",
+ arcz_missing="26 3. 6.",
+ )
+
def test_generator_expression(self):
# Generator expression:
self.check_coverage("""\