summaryrefslogtreecommitdiff
path: root/tests/test_parser.py
diff options
context:
space:
mode:
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 18621d15..84b9a214 100644
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -8,6 +8,7 @@ import textwrap
from tests.coveragetest import CoverageTest
from coverage import env
+from coverage.misc import NotPython
from coverage.parser import PythonParser
@@ -116,6 +117,25 @@ class PythonParserTest(CoverageTest):
""")
self.assertEqual(parser.exit_counts(), { 1:1, 2:1, 3:1, 6:1 })
+ def test_indentation_error(self):
+ msg = (
+ "Couldn't parse '<code>' as Python source: "
+ "'unindent does not match any outer indentation level' at line 3"
+ )
+ with self.assertRaisesRegex(NotPython, msg):
+ _ = self.parse_source("""\
+ 0 spaces
+ 2
+ 1
+ """)
+
+ def test_token_error(self):
+ msg = "Couldn't parse '<code>' as Python source: 'EOF in multi-line string' at line 1"
+ with self.assertRaisesRegex(NotPython, msg):
+ _ = self.parse_source("""\
+ '''
+ """)
+
class ParserFileTest(CoverageTest):
"""Tests for coverage.py's code parsing from files."""