Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make JUnitXml.from* methods return only JUnitXml instances #142

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

EnricoMi
Copy link
Collaborator

@EnricoMi EnricoMi commented Dec 20, 2024

For the sake of consistency, JUnitXml.fromfile, JUnitXml.fromstring and JUnitXml.fromroot should always return a JUnitXml instance. Currently, when the root element of the XML document is a <TestSuite> tag, it would return a TestSuite instance. This causes confusion: #110, #111, #140.

This fact affects behavior of iterating the instance (as given in the examples), it iterates TestCase instances, not TestSuite instances:

from junitparser import JUnitXml

xml = JUnitXml.fromfile('/path/to/junit.xml')
for suite in xml:
    # handle suites
    for case in suite:
        # handle cases

https://github.com/weiwei/junitparser?tab=readme-ov-file#read-and-manipulate-existing-junitxunit-xml-files

Note: This is a breaking change.

Fixes #110
Fixes #111
Fixes #140

Based on #143, rebase after that has been merged.

@EnricoMi EnricoMi force-pushed the from-methods-return-type branch from 5ec9ccb to 2095372 Compare January 29, 2025 11:20
@EnricoMi EnricoMi marked this pull request as ready for review January 29, 2025 11:20
Copy link

github-actions bot commented Jan 29, 2025

Test Results

  4 files  ±0    4 suites  ±0   1s ⏱️ ±0s
102 tests +1  102 ✅ +1  0 💤 ±0  0 ❌ ±0 
408 runs  +4  399 ✅ +4  9 💤 ±0  0 ❌ ±0 

Results for commit 5cbf10d. ± Comparison against base commit 16c54d7.

♻️ This comment has been updated with latest results.

@EnricoMi EnricoMi force-pushed the from-methods-return-type branch from 2095372 to 5cbf10d Compare January 29, 2025 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant