From 1f620f8581a6661a9b5ec78beaf77ae5a8ebf41c Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 19 Jul 2021 07:51:03 -0400 Subject: 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. --- tests/test_arcs.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) 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("""\ -- cgit v1.2.1