Skip to content

Commit 7eaf92a

Browse files
committed
Ensure the user-defined (or default) regexes are only checked if there is no match for the DSL regex or an error.
1 parent 7dc5323 commit 7eaf92a

File tree

8 files changed

+31
-6
lines changed

8 files changed

+31
-6
lines changed

cov-report.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
plugins = coverage_pyver_pragma
33

44
[report]
5-
fail_under = 80
5+
fail_under = 95
66
exclude_lines =
77
raise AssertionError
88
raise NotImplementedError

coverage_pyver_pragma/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ def lines_matching(self, *regexes): # noqa: D102
9191
with suppress(pyparsing.ParseBaseException):
9292
if evaluate_exclude(exclude_source):
9393
matches.add(idx)
94-
continue
94+
95+
continue
9596

9697
if regex_c.search(ltext):
9798
matches.add(idx)

tests/demo_code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
pass
66
elif sys.version_info[:2] == (3, 9): # pragma: no cover (!py39)
77
pass
8-
else: # pragma: no cover (<py38 or <py39)
8+
else: # pragma: no cover (<py38)
99
pass

tests/test_plugin.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
# 3rd party
66
import coverage # type: ignore
7+
import pytest
8+
from coincidence import only_version
79
from coincidence.regressions import check_file_regression
810
from coverage.python import PythonParser # type: ignore
911
from domdf_python_tools.paths import PathPlus
@@ -13,7 +15,13 @@
1315
import coverage_pyver_pragma
1416

1517

16-
def test_plugin(tmp_pathplus: PathPlus, file_regression: FileRegressionFixture):
18+
@pytest.mark.parametrize("version", [
19+
pytest.param("3.6", marks=only_version(3.6, "Output differs on each version.")),
20+
pytest.param("3.7", marks=only_version(3.7, "Output differs on each version.")),
21+
pytest.param("3.8", marks=only_version(3.8, "Output differs on each version.")),
22+
pytest.param("3.9", marks=only_version(3.9, "Output differs on each version.")),
23+
])
24+
def test_plugin(tmp_pathplus: PathPlus, file_regression: FileRegressionFixture, version):
1725
coverage_pyver_pragma.coverage_init()
1826

1927
assert PythonParser.lines_matching is coverage_pyver_pragma.PythonParser.lines_matching
@@ -29,6 +37,7 @@ def test_plugin(tmp_pathplus: PathPlus, file_regression: FileRegressionFixture):
2937

3038
output = StringIO()
3139
cov.report(morfs=[tests.demo_code.__file__], file=output)
40+
# cov.html_report(morfs=[tests.demo_code.__file__])
3241
cov.erase()
3342

3443
buf = output.getvalue().replace(tests.demo_code.__file__, "demo_code.py")
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Name Stmts Miss Cover
22
----------------------------------------
3-
tests/demo_code.py 1 0 100%
3+
tests/demo_code.py 3 0 100%
44
----------------------------------------
5-
TOTAL 1 0 100%
5+
TOTAL 3 0 100%
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Name Stmts Miss Cover
2+
----------------------------------------
3+
tests/demo_code.py 3 0 100%
4+
----------------------------------------
5+
TOTAL 3 0 100%
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Name Stmts Miss Cover
2+
----------------------------------------
3+
tests/demo_code.py 2 0 100%
4+
----------------------------------------
5+
TOTAL 2 0 100%
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Name Stmts Miss Cover
2+
----------------------------------------
3+
tests/demo_code.py 4 0 100%
4+
----------------------------------------
5+
TOTAL 4 0 100%

0 commit comments

Comments
 (0)