Closed guilhem-martin closed 11 months ago
Alternative is to check junitxml._tag
. I do:
suites = [suite for suite in (junitxml if junitxml._tag == "testsuites" else [junitxml])]
Junitparser could always return a TestSuites, even if the file itself contains a TestSuite as root.
Technically, this wouldn't even be a breaking change, but it should be considered one as behaviour for the same file changes.
Thanks @EnricoMi , looks elegant.
@weiwei what do you think about Junitparser always returning a TestSuites?
Frankly I'm not sure. I think it eases things for me a bit? I'm open to suggestions though.
Closing because this is rather old. But if needed we can reopen and discuss again.
what do you think about Junitparser always returning a TestSuites?
IMHO it should always return a TestSuites object. Forcing the user to examine the returned object is not optimal.
Alternative is to check
junitxml._tag
. I do:suites = [suite for suite in (junitxml if junitxml._tag == "testsuites" else [junitxml])]
This should be sufficient:
suites = junitxml if junitxml._tag == "testsuites" else [junitxml]
Hello,
As JUnit XML file inputs, I get sometimes TestSuite as root and sometimes TestSuites, which is as expected from the JUnit XSD file definition.
To be able to know in which case I'm, I do:
Then depending on whether instance_type is JUnitXml or TestSuite, I'll parse differently.
Is this the proper way of dealing with the JUnit XML file root element variance when using junitparser module?
thanks.