pytest-dev / pytest-dev/pytest
subtests not itemized in Junit XML
Open
Nobody has claimed this yet.
plugin: junitxml
plugin: subtests
- Dominant language
- Python
- Stars
- 14.5k
- Forks
- 3.4k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 35
Description
Testing with tip-of-main to try out new subtests integration. Simple subtest example
def test_subtests(subtests):
"""Simple subtest example"""
for i in range(2):
with subtests.test(msg="is_even", i=i):
assert i % 2 == 0, f"{i} is odd"
I expect each subtest to appear as a in a generated JUnit XML. Instead, only the top level is:
<testcase classname="samples.test_sample" name="test_subtests" time="0.006">
<failure message="AssertionError: 1 is odd assert (1 % 2) == 0">subtests = <_pytest.subtests.Subtests object at 0x103b1d580>
def test_subtests(subtests):
"""Simple subtest example"""
for i in range(2):
with subtests.test(msg="is_even", i=i):
> assert i % 2 == 0, f"{i} is odd"
E AssertionError: 1 is odd
E assert (1 % 2) == 0
samples/test_sample.py:87: AssertionError</failure><system-out>--------------------------------- Captured Log ---------------------------------
</system-out>
<failure message="contains 1 failed subtest">contains 1 failed subtest</failure>
<system-out>--------------------------------- Captured Log ---------------------------------
</system-out>
</testcase>
- a detailed description of the bug or problem you are having
- output of
pip listfrom the virtual environment you are using - pytest and operating system versions
- minimal example if possible
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the subtest example in samples/test_sample.py, especially test_subtests at line 87, and inspect the generated JUnit XML. Trace how pytest's subtests integration is represented by the JUnit reporting path. Done means each subtest appears as its own while the report still represents the top-level test correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100