Skip to content

Commit 36ecc73

Browse files
committed
data.line(contexts=) expects a glob pattern.
1 parent afe3f00 commit 36ecc73

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

tests/contextful.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ def test_08(expensive_data):
7272

7373
@pytest.fixture(params=[1, 2, 3])
7474
def parametrized_number(request):
75-
return request.param # x9-1 x9-2 x9-3
75+
return request.param # s9-1 s9-2 s9-3
7676

7777

7878
def test_09(parametrized_number):
79-
assert parametrized_number > 0 # x9-1 x9-2 x9-3
79+
assert parametrized_number > 0 # r9-1 r9-2 r9-3
8080

8181

8282
def test_10():

tests/test_pytest_cov.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1942,7 +1942,7 @@ def find_labels(text, pattern):
19421942
return all_labels
19431943

19441944

1945-
# The contexts in contextful.py
1945+
# The contexts and their labels in contextful.py
19461946
EXPECTED_CONTEXTS = {
19471947
'': 'c0',
19481948
'test_contexts.py::test_01|run': 'r1',
@@ -1995,7 +1995,9 @@ def test_contexts(testdir, opts):
19951995
for context, label in EXPECTED_CONTEXTS.items():
19961996
if context == '':
19971997
continue
1998-
assert data.lines(test_context_path, contexts=[context]) == line_data[label], "Wrong lines for context {!r}".format(context)
1998+
context_pattern = re.sub(r"[\[\|]", r"[\g<0>]", context)
1999+
actual = data.lines(test_context_path, contexts=[context_pattern])
2000+
assert line_data[label] == actual, "Wrong lines for context {!r}".format(context)
19992001

20002002

20012003
@pytest.mark.skipif("coverage.version_info >= (5, 0)")

0 commit comments

Comments
 (0)