summaryrefslogtreecommitdiff
path: root/tests/test_parser.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-11-10 21:53:06 -0500
committerNed Batchelder <ned@nedbatchelder.com>2021-11-10 21:53:06 -0500
commit0387bbaa5e9ab2ad834311249802695ebb0c34ca (patch)
tree81eba7ac0b1fe21c4ad3230efcc9a97fe920e606 /tests/test_parser.py
parentd1d60a72cd60b2472d02cdbbcb487e31f25fe32a (diff)
downloadpython-coveragepy-git-0387bbaa5e9ab2ad834311249802695ebb0c34ca.tar.gz
fix: colons in decorators shouldn't stop an exclusion
Diffstat (limited to 'tests/test_parser.py')
-rw-r--r--tests/test_parser.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/test_parser.py b/tests/test_parser.py
index d5f43197..303f2b55 100644
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -174,10 +174,30 @@ class PythonParserTest(CoverageTest):
""")
raw_statements = {3, 4, 5, 6, 8, 9, 10, 13, 15, 16, 17, 20, 22, 23, 25, 26}
if env.PYBEHAVIOR.trace_decorated_def:
- raw_statements.update([11, 19])
+ raw_statements.update({11, 19})
assert parser.raw_statements == raw_statements
assert parser.statements == {8}
+ def test_decorator_pragmas_with_colons(self):
+ # A colon in a decorator expression would confuse the parser,
+ # ending the exclusion of the decorated function.
+ parser = self.parse_source("""\
+ @decorate(X) # nocover
+ @decorate("Hello"[2])
+ def f():
+ x = 4
+
+ @decorate(X) # nocover
+ @decorate("Hello"[:7])
+ def g():
+ x = 9
+ """)
+ raw_statements = {1, 2, 4, 6, 7, 9}
+ if env.PYBEHAVIOR.trace_decorated_def:
+ raw_statements.update({3, 8})
+ assert parser.raw_statements == raw_statements
+ assert parser.statements == set()
+
def test_class_decorator_pragmas(self):
parser = self.parse_source("""\
class Foo(object):