Skip to content

Commit 4b72162

Browse files
committed
compatible no_fnmatch_line()
1 parent bb67f70 commit 4b72162

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

plugin_test.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
import pytest
33
from packaging import version
44

5+
# result.stdout.no_fnmatch_line() is added to testdir on pytest 5.3.0
6+
# https://docs.pytest.org/en/stable/changelog.html#pytest-5-3-0-2019-11-19
7+
def no_fnmatch_line(result, pattern):
8+
if version.parse(pytest.__version__) >= version.parse('5.3.0'):
9+
result.stdout.no_fnmatch_line(
10+
pattern + '*',
11+
)
12+
else:
13+
assert pattern not in result.stdout.str()
14+
515
def test_annotation_succeed_no_output(testdir):
616
testdir.makepyfile(
717
'''
@@ -15,14 +25,7 @@ def test_success():
1525
testdir.monkeypatch.setenv('GITHUB_ACTIONS', 'true')
1626
result = testdir.runpytest_subprocess()
1727

18-
# no_fnmatch_line() is added to testdir on pytest 5.3.0
19-
# https://docs.pytest.org/en/stable/changelog.html#pytest-5-3-0-2019-11-19
20-
if version.parse(pytest.__version__) >= version.parse('5.3.0'):
21-
result.stdout.no_fnmatch_line(
22-
'::error file=test_annotation_succeed_no_output.py*',
23-
)
24-
else:
25-
assert '::error file=test_annotation_succeed_no_output.py' not in result.stdout.str()
28+
no_fnmatch_line(result, '::error file=test_annotation_succeed_no_output.py')
2629

2730
def test_annotation_fail(testdir):
2831
testdir.makepyfile(
@@ -69,6 +72,4 @@ def test_fail():
6972
)
7073
testdir.monkeypatch.setenv('GITHUB_ACTIONS', '')
7174
result = testdir.runpytest_subprocess()
72-
result.stdout.no_fnmatch_line(
73-
'::error file=test_annotation_fail_disabled_outside_workflow.py*',
74-
)
75+
no_fnmatch_line(result, '::error file=test_annotation_fail_disabled_outside_workflow.py')

0 commit comments

Comments
 (0)