Skip to content

Commit bb67f70

Browse files
committed
use assert ... in ... when using pytest earlier with 5.3.0
1 parent 34ecfe3 commit bb67f70

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232
- name: Install dependencies
3333
run: |
3434
python -m pip install --upgrade pip
35+
pip install -r requirements.txt
3536
pip install pytest==${{ matrix.pytest-version }}
3637
3738
- name: Install itself

plugin_test.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
pytest_plugins = 'pytester'
22
import pytest
3+
from packaging import version
34

45
def test_annotation_succeed_no_output(testdir):
56
testdir.makepyfile(
@@ -13,9 +14,15 @@ def test_success():
1314
)
1415
testdir.monkeypatch.setenv('GITHUB_ACTIONS', 'true')
1516
result = testdir.runpytest_subprocess()
16-
result.stdout.no_fnmatch_line(
17-
'::error file=test_annotation_succeed_no_output.py*',
18-
)
17+
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()
1926

2027
def test_annotation_fail(testdir):
2128
testdir.makepyfile(

0 commit comments

Comments
 (0)