@@ -11,7 +11,8 @@ def test_success():
11
11
assert 1
12
12
'''
13
13
)
14
- result = testdir .runpytest ()
14
+ testdir .monkeypatch .setenv ('GITHUB_ACTIONS' , 'true' )
15
+ result = testdir .runpytest_subprocess ()
15
16
result .stdout .no_fnmatch_line (
16
17
'::error file=test_annotation_succeed_no_output.py*' ,
17
18
)
@@ -26,7 +27,8 @@ def test_fail():
26
27
assert 0
27
28
'''
28
29
)
29
- result = testdir .runpytest ()
30
+ testdir .monkeypatch .setenv ('GITHUB_ACTIONS' , 'true' )
31
+ result = testdir .runpytest_subprocess ()
30
32
result .stdout .fnmatch_lines ([
31
33
'::error file=test_annotation_fail.py,line=4::def test_fail():*' ,
32
34
])
@@ -42,7 +44,24 @@ def test_fail():
42
44
assert 1
43
45
'''
44
46
)
45
- result = testdir .runpytest ()
47
+ testdir .monkeypatch .setenv ('GITHUB_ACTIONS' , 'true' )
48
+ result = testdir .runpytest_subprocess ()
46
49
result .stdout .fnmatch_lines ([
47
50
'::error file=test_annotation_exception.py,line=4::def test_fail():*' ,
48
51
])
52
+
53
+ def test_annotation_fail_disabled_outside_workflow (testdir ):
54
+ testdir .makepyfile (
55
+ '''
56
+ import pytest
57
+ pytest_plugins = 'pytest_github_actions_annotate_failures'
58
+
59
+ def test_fail():
60
+ assert 0
61
+ '''
62
+ )
63
+ testdir .monkeypatch .setenv ('GITHUB_ACTIONS' , '' )
64
+ result = testdir .runpytest_subprocess ()
65
+ result .stdout .no_fnmatch_line (
66
+ '::error file=test_annotation_fail_disabled_outside_workflow.py*' ,
67
+ )
0 commit comments