Skip to content

Commit 058b1be

Browse files
authored
Merge pull request #10 from utgwkk/python2.7-support
Python 2.7 support
2 parents 62d1972 + 4b72162 commit 058b1be

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

.github/workflows/test.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,15 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
python-version: [3.5, 3.6, 3.7, 3.8]
15+
python-version: [2.7, 3.5, 3.6, 3.7, 3.8]
16+
pytest-version: [4.6.11, 5.4.3]
1617

18+
exclude:
19+
# pytest 5.x.x doesn't support Python 2.7
20+
- python-version: 2.7
21+
pytest-version: 5.4.3
22+
23+
name: Python ${{ matrix.python-version }}, pytest ${{ matrix.pytest-version }}
1724
steps:
1825
- uses: actions/checkout@v2
1926

@@ -26,6 +33,7 @@ jobs:
2633
run: |
2734
python -m pip install --upgrade pip
2835
pip install -r requirements.txt
36+
pip install pytest==${{ matrix.pytest-version }}
2937
3038
- name: Install itself
3139
run: python setup.py install

plugin_test.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
pytest_plugins = 'pytester'
22
import pytest
3+
from packaging import version
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()
314

415
def test_annotation_succeed_no_output(testdir):
516
testdir.makepyfile(
@@ -13,9 +24,8 @@ def test_success():
1324
)
1425
testdir.monkeypatch.setenv('GITHUB_ACTIONS', 'true')
1526
result = testdir.runpytest_subprocess()
16-
result.stdout.no_fnmatch_line(
17-
'::error file=test_annotation_succeed_no_output.py*',
18-
)
27+
28+
no_fnmatch_line(result, '::error file=test_annotation_succeed_no_output.py')
1929

2030
def test_annotation_fail(testdir):
2131
testdir.makepyfile(
@@ -62,6 +72,4 @@ def test_fail():
6272
)
6373
testdir.monkeypatch.setenv('GITHUB_ACTIONS', '')
6474
result = testdir.runpytest_subprocess()
65-
result.stdout.no_fnmatch_line(
66-
'::error file=test_annotation_fail_disabled_outside_workflow.py*',
67-
)
75+
no_fnmatch_line(result, '::error file=test_annotation_fail_disabled_outside_workflow.py')

pytest_github_actions_annotate_failures/plugin.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
import os
23

34
def pytest_runtest_logreport(report):
@@ -33,5 +34,5 @@ def _error_workflow_command(filesystempath, lineno, longrepr):
3334
longrepr = _escape(longrepr)
3435
return '\n::error file={},line={}::{}'.format(filesystempath, lineno, longrepr)
3536

36-
def _escape(s: str):
37+
def _escape(s):
3738
return s.replace('%', '%25').replace('\r', '%0D').replace('\n', '%0A')

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pytest==5.4.2
1+
packaging==20.4

0 commit comments

Comments
 (0)