Skip to content

Commit ac23f15

Browse files
Support Pytest 9+ subtests
1 parent 3b7d7db commit ac23f15

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

plugin_test.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,31 @@ def test_param(a, b):
327327
)
328328

329329

330+
@pytest.mark.skipif(
331+
version.parse("9.0.0") > PYTEST_VERSION,
332+
reason="subtests are only supported in pytest 9+",
333+
)
334+
def test_annotation_subtest(testdir: pytest.Testdir):
335+
testdir.makepyfile(
336+
"""
337+
import pytest
338+
pytest_plugins = 'pytest_github_actions_annotate_failures'
339+
340+
def test(subtests):
341+
for i in range(5):
342+
with subtests.test(msg="custom message", i=i):
343+
assert i % 2 == 0
344+
"""
345+
)
346+
testdir.monkeypatch.setenv("GITHUB_ACTIONS", "true")
347+
result = testdir.runpytest_subprocess()
348+
result.stderr.fnmatch_lines(
349+
[
350+
"::error file=test_annotation_subtest.py,line=7::test?custom message?0*assert 1 == 0*",
351+
]
352+
)
353+
354+
330355
# Debugging / development tip:
331356
# Add a breakpoint() to the place you are going to check,
332357
# uncomment this example, and run it with:

0 commit comments

Comments
 (0)