2
2
import pytest
3
3
from packaging import version
4
4
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
+
5
15
def test_annotation_succeed_no_output (testdir ):
6
16
testdir .makepyfile (
7
17
'''
@@ -15,14 +25,7 @@ def test_success():
15
25
testdir .monkeypatch .setenv ('GITHUB_ACTIONS' , 'true' )
16
26
result = testdir .runpytest_subprocess ()
17
27
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' )
26
29
27
30
def test_annotation_fail (testdir ):
28
31
testdir .makepyfile (
@@ -69,6 +72,4 @@ def test_fail():
69
72
)
70
73
testdir .monkeypatch .setenv ('GITHUB_ACTIONS' , '' )
71
74
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