-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Toggle JUnit behavior with INI option #4511
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
Conversation
Also, I left #4493 intact in case this PR is considered "too crazy". |
at first glance interesting approach - unfortunately i might not be able to review it in a timely manner this week |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after doing a first deeper review i really like the approach,
it keeps things as they are reasonably simple
the reduction of the detail level of the testcases doesn't sit too well with me, but i would prefer if someone with a deep need for correct and detailed junitxml sorted that out
src/_pytest/junitxml.py
Outdated
for kl, vl in left.items(): | ||
for kr, vr in right.items(): | ||
if not isinstance(vl, list): | ||
raise NotImplementedError(type(vl)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be a TypeError
# This includes custom attributes, because they are not valid here. | ||
# TODO: Convert invalid attributes to properties to preserve "something" | ||
temp_attrs = {} | ||
for key in self.attrs.keys(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should jsut use items()
to avoid double lookup
src/_pytest/junitxml.py
Outdated
merge_family(families["xunit1"], families["_base_old"]) | ||
|
||
# Alias "old" to xUnit 1.x | ||
families["old"] = families["xunit1"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of old
i propose the name legacy
src/_pytest/junitxml.py
Outdated
tests=numtests, | ||
time="%.3f" % suite_time_delta, | ||
).unicode(indent=0) | ||
) | ||
logfile.close() | ||
|
||
# TODO: GET RID OF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO
changelog/3547.bugfix.rst
Outdated
@@ -0,0 +1 @@ | |||
``--junitxml`` emits XML data compatible with JUnit's offical schema releases. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a link to the official document
bd44911
to
69c5fde
Compare
Codecov Report
@@ Coverage Diff @@
## features #4511 +/- ##
===========================================
- Coverage 95.76% 92% -3.76%
===========================================
Files 111 111
Lines 24683 24636 -47
Branches 2446 2445 -1
===========================================
- Hits 23637 22666 -971
- Misses 739 1566 +827
- Partials 307 404 +97
Continue to review full report at Codecov.
|
* Remove non-standard testcase elements: 'file' and 'line' * Replace testcase element 'skips' with 'skipped' * Time resolution uses the standard format: 0.000 * Tests use corrected XML output with proper attributes
* "legacy" is no longer a copy of "xunit1" * Attempts to use "legacy" will redirect to "xunit1" * record_xml_attribute is not compatible outside of legacy family * Replace call to method/override raw() with to_xml()
2a09992
to
85c5fa9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks @jhunkeler!
Can we remove the |
Thanks :) I do have one concern though. This PR tries to retain backwards compatibility but it did fall short in one place. Originally this code used That's to say with I'm not sure if this is a showstopper so I'd like to get an opinion on the matter. |
a nicely self-contained if/else with a todo comment and followup issue is a good starting point - eventually we ought to investigate if it can be done nicely with inheritance or another mechanism |
I agree, if we move the logic to a free function I think the code still will be ok |
After looking around at some xUnit schemas, indeed I propose we merge this as is and deal with any problems later in a bug-fix release, if they ever happen. |
Due to the XML file containing the word "skipped" instead of "skips", as of pytest version 4.2.0, the JUnit plugin in Jenkins fails to parse the XML file if you are using the post-build step "Publish JUnit reports generated with handlebars". I don't make use of the webpage that build step generates, so I just removed the step from my builds. In case anyone happens to come across this error and spend several hours troubleshooting it, there's the solution. Downgrade Pytest or get rid of that build step in Jenkins. |
Hi @ianling, Did you try to set the |
Continuation of #4493
cc: @nicoddemus @RonnyPfannschmidt
Known issues so far:
_NodeReporter
orLogXML
about which family they should choose. Not without horrifically breaking either of them.Note:
Despite the tests failing this does emit different/corrected XML for the selected
junit_family=[(old|xunit1),xunit2]
.