@@ -41,7 +41,7 @@ def test_fail():
41
41
testdir .monkeypatch .setenv ('GITHUB_ACTIONS' , 'true' )
42
42
result = testdir .runpytest_subprocess ()
43
43
result .stdout .fnmatch_lines ([
44
- '::error file=test_annotation_fail.py,line=4::def test_fail(): *' ,
44
+ '::error file=test_annotation_fail.py,line=5:: test_fail*assert 0 *' ,
45
45
])
46
46
47
47
def test_annotation_exception (testdir ):
@@ -58,7 +58,7 @@ def test_fail():
58
58
testdir .monkeypatch .setenv ('GITHUB_ACTIONS' , 'true' )
59
59
result = testdir .runpytest_subprocess ()
60
60
result .stdout .fnmatch_lines ([
61
- '::error file=test_annotation_exception.py,line=4::def test_fail(): *' ,
61
+ '::error file=test_annotation_exception.py,line=5:: test_fail*oops *' ,
62
62
])
63
63
64
64
def test_annotation_fail_disabled_outside_workflow (testdir ):
@@ -73,7 +73,7 @@ def test_fail():
73
73
)
74
74
testdir .monkeypatch .setenv ('GITHUB_ACTIONS' , '' )
75
75
result = testdir .runpytest_subprocess ()
76
- no_fnmatch_line (result , '::error file=test_annotation_fail_disabled_outside_workflow.py' )
76
+ no_fnmatch_line (result , '::error file=test_annotation_fail_disabled_outside_workflow.py* ' )
77
77
78
78
def test_annotation_fail_cwd (testdir ):
79
79
testdir .makepyfile (
@@ -91,5 +91,87 @@ def test_fail():
91
91
testdir .makefile ('.ini' , pytest = '[pytest]\n testpaths=..' )
92
92
result = testdir .runpytest_subprocess ('--rootdir=foo' )
93
93
result .stdout .fnmatch_lines ([
94
- '::error file=test_annotation_fail_cwd.py,line=4::def test_fail(): *' ,
94
+ '::error file=test_annotation_fail_cwd.py,line=5:: test_fail*assert 0 *' ,
95
95
])
96
+
97
+ def test_annotation_long (testdir ):
98
+ testdir .makepyfile (
99
+ '''
100
+ import pytest
101
+ pytest_plugins = 'pytest_github_actions_annotate_failures'
102
+
103
+ def f(x):
104
+ return x
105
+
106
+ def test_fail():
107
+ x = 1
108
+ x += 1
109
+ x += 1
110
+ x += 1
111
+ x += 1
112
+ x += 1
113
+ x += 1
114
+ x += 1
115
+
116
+ assert f(x) == 3
117
+ '''
118
+ )
119
+ testdir .monkeypatch .setenv ('GITHUB_ACTIONS' , 'true' )
120
+ result = testdir .runpytest_subprocess ()
121
+ result .stdout .fnmatch_lines ([
122
+ '::error file=test_annotation_long.py,line=17::test_fail*assert 8 == 3*where 8 = f(8)*' ,
123
+ ])
124
+ no_fnmatch_line (result , '::*assert x += 1*' )
125
+
126
+ def test_class_method (testdir ):
127
+ testdir .makepyfile (
128
+ '''
129
+ import pytest
130
+ pytest_plugins = 'pytest_github_actions_annotate_failures'
131
+
132
+ class TestClass(object):
133
+ def test_method(self):
134
+ x = 1
135
+ assert x == 2
136
+ '''
137
+ )
138
+ testdir .monkeypatch .setenv ('GITHUB_ACTIONS' , 'true' )
139
+ result = testdir .runpytest_subprocess ()
140
+ result .stdout .fnmatch_lines ([
141
+ '::error file=test_class_method.py,line=7::TestClass.test_method*assert 1 == 2*' ,
142
+ ])
143
+ no_fnmatch_line (result , '::*x = 1*' )
144
+
145
+
146
+
147
+
148
+ def test_annotation_param (testdir ):
149
+ testdir .makepyfile (
150
+ '''
151
+ import pytest
152
+ pytest_plugins = 'pytest_github_actions_annotate_failures'
153
+
154
+ @pytest.mark.parametrize("a", [1])
155
+ @pytest.mark.parametrize("b", [2], ids=["other"])
156
+ def test_param(a, b):
157
+
158
+ a += 1
159
+ b += 1
160
+
161
+ assert a == b
162
+ '''
163
+ )
164
+ testdir .monkeypatch .setenv ('GITHUB_ACTIONS' , 'true' )
165
+ result = testdir .runpytest_subprocess ()
166
+ result .stdout .fnmatch_lines ([
167
+ '::error file=test_annotation_param.py,line=11::test_param?other?1*assert 2 == 3*' ,
168
+ ])
169
+
170
+ # Debugging / development tip:
171
+ # Add a breakpoint() to the place you are going to check,
172
+ # uncomment this example, and run it with:
173
+ # GITHUB_ACTIONS=true pytest -k test_example
174
+ # def test_example():
175
+ # x = 3
176
+ # y = 4
177
+ # assert x == y
0 commit comments