summaryrefslogtreecommitdiff
path: root/tests/test_parser.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2016-02-08 09:54:24 -0500
committerNed Batchelder <ned@nedbatchelder.com>2016-02-08 09:54:24 -0500
commit429d6ecbc19bf4e742170828e0433481ee0d3b19 (patch)
tree81305a30496855756ef01237518a532d3bca1279 /tests/test_parser.py
parentf0eb7f779f14cce5fc34581439c25cfa5c13d23a (diff)
downloadpython-coveragepy-429d6ecbc19bf4e742170828e0433481ee0d3b19.tar.gz
missing_arc_description is better than arc_destination_description. One test broken.
Diffstat (limited to 'tests/test_parser.py')
-rw-r--r--tests/test_parser.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/test_parser.py b/tests/test_parser.py
index 470ea15..48b70ef 100644
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -186,6 +186,38 @@ class PythonParserTest(CoverageTest):
self.assertEqual(parser.statements, set([1, 2, 3]))
+class ParserMissingArcDescriptionTest(CoverageTest):
+ """Tests for PythonParser.missing_arc_description."""
+
+ run_in_temp_dir = False
+
+ def test_missing_arc_description(self):
+ text = textwrap.dedent("""\
+ if x:
+ print(2)
+ print(3)
+
+ def func5():
+ for x in range(6):
+ if x == 3:
+ break
+ """)
+ parser = PythonParser(text=text)
+ parser.parse_source()
+ self.assertEqual(
+ parser.missing_arc_description(1, 2),
+ "line 1 didn't jump to line 2, because the condition on line 1 was never true"
+ )
+ self.assertEqual(
+ parser.missing_arc_description(1, 3),
+ "line 1 didn't jump to line 3, because the condition on line 1 was never false"
+ )
+ self.assertEqual(
+ parser.missing_arc_description(6, -5),
+ "line 6 didn't return from function 'func5', because the loop on line 6 didn't complete"
+ )
+
+
class ParserFileTest(CoverageTest):
"""Tests for coverage.py's code parsing from files."""