summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2018-11-20 05:33:23 -0500
committerNed Batchelder <ned@nedbatchelder.com>2018-11-20 05:33:23 -0500
commit921ebfadc0ace5ec8e4d4ff606940af54b9cacfa (patch)
tree0e60870bbff58d53d489d751f5288b03a2e628cc
parente6b883903e6f0eb396d35d43ff82c3c5644af84c (diff)
downloadpython-coveragepy-git-nedbat/while-edge-tests.tar.gz
WIP: tests for unusual while loopsnedbat/while-edge-tests
-rw-r--r--coverage/parser.py2
-rw-r--r--tests/test_arcs.py39
2 files changed, 39 insertions, 2 deletions
diff --git a/coverage/parser.py b/coverage/parser.py
index 1c19f69e..61a69e81 100644
--- a/coverage/parser.py
+++ b/coverage/parser.py
@@ -770,8 +770,6 @@ class AstArcAnalyzer(object):
return None
# In the fullness of time, these might be good tests to write:
- # while EXPR:
- # while False:
# listcomps hidden deep in other expressions
# listcomps hidden in lists: x = [[i for i in range(10)]]
# nested function definitions
diff --git a/tests/test_arcs.py b/tests/test_arcs.py
index d3430af2..a952ee3d 100644
--- a/tests/test_arcs.py
+++ b/tests/test_arcs.py
@@ -283,6 +283,45 @@ class LoopArcTest(CoverageTest):
arcz=arcz,
)
+ def test_todo1(self):
+ self.check_coverage("""\
+ a = 1
+ while True:
+ a = 3
+ break
+ assert a == 3
+ """,
+ arcz = ".1 12 23 34 45 5.",
+ arcz_missing = "",
+ )
+ def test_todo3(self):
+ self.check_coverage("""\
+ a = 1
+ while False:
+ a = 3
+ break
+ assert a == 1
+ """,
+ arcz = ".1 12 23 34 45 5.",
+ arcz_missing = "34 45",
+ )
+ def test_todo2(self):
+ self.check_coverage("""\
+ a = 1
+ while True:
+ a = 3
+ break
+ else:
+ a = 6
+ assert a == 3
+ """,
+ arcz = ".1 12 23 34 47 7. 67",
+ arcz_missing = "67",
+ )
+ assert "while True with else" == "done"
+ assert "while False with else" == "done"
+ assert "while if continue else break" == "done"
+
def test_zero_coverage_while_loop(self):
# https://bitbucket.org/ned/coveragepy/issue/502
self.make_file("main.py", "print('done')")