Toggle JUnit behavior with INI option#4511
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 |
RonnyPfannschmidt
left a comment
There was a problem hiding this comment.
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.
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.
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.
instead of old i propose the name legacy
src/_pytest/junitxml.py
Outdated
| ) | ||
| logfile.close() | ||
|
|
||
| # TODO: GET RID OF |
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.
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
nicoddemus
left a comment
There was a problem hiding this comment.
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:
_NodeReporterorLogXMLabout 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].