summaryrefslogtreecommitdiff
path: root/tests/test_parser.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2016-02-13 17:41:51 -0500
committerNed Batchelder <ned@nedbatchelder.com>2016-02-13 17:41:51 -0500
commit1816fad451ba00d669efba1211c136dbbef52c61 (patch)
tree67c4e12dab8242de74eb1751553b074a9723a451 /tests/test_parser.py
parentff84e43cdb213454d57317db85fe426438c653ca (diff)
downloadpython-coveragepy-1816fad451ba00d669efba1211c136dbbef52c61.tar.gz
Add missing branch descriptions for handling exceptions
Diffstat (limited to 'tests/test_parser.py')
-rw-r--r--tests/test_parser.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_parser.py b/tests/test_parser.py
index 53a514e..d978134 100644
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -250,6 +250,26 @@ class ParserMissingArcDescriptionTest(CoverageTest):
"line 5 didn't run the set comprehension on line 5"
)
+ def test_missing_arc_descriptions_for_exceptions(self):
+ text = textwrap.dedent(u"""\
+ try:
+ pass
+ except ZeroDivideError:
+ print("whoops")
+ except ValueError:
+ print("yikes")
+ """)
+ parser = PythonParser(text=text)
+ parser.parse_source()
+ self.assertEqual(
+ parser.missing_arc_description(3, 4),
+ "line 3 didn't jump to line 4, because the exception caught by line 3 didn't happen"
+ )
+ self.assertEqual(
+ parser.missing_arc_description(5, 6),
+ "line 5 didn't jump to line 6, because the exception caught by line 5 didn't happen"
+ )
+
class ParserFileTest(CoverageTest):
"""Tests for coverage.py's code parsing from files."""