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

Show XFail reason as part of JUnitXML message field #5087

Merged
merged 1 commit into from
Apr 11, 2019
Merged

Show XFail reason as part of JUnitXML message field #5087

merged 1 commit into from
Apr 11, 2019

Conversation

samueljsb
Copy link
Contributor

Fixes #4907

src/_pytest/junitxml.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Apr 10, 2019

Codecov Report

Merging #5087 into features will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##           features    #5087      +/-   ##
============================================
+ Coverage     96.09%   96.09%   +<.01%     
============================================
  Files           115      115              
  Lines         25894    25907      +13     
  Branches       2560     2561       +1     
============================================
+ Hits          24883    24896      +13     
  Misses          704      704              
  Partials        307      307
Impacted Files Coverage Δ
testing/test_junitxml.py 97.84% <100%> (+0.03%) ⬆️
src/_pytest/junitxml.py 95.25% <100%> (+0.04%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 97cd5f0...a37d1df. Read the comment docs.

Copy link
Contributor

@blueyed blueyed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but that's not my area of expertise.

@nicoddemus
Copy link
Member

Hi @samueljsb, thanks for the PR!

Current master generates:

<?xml version="1.0" encoding="utf-8"?>
<testsuite errors="0" failures="0" name="pytest" skipped="1" tests="2" time="0.096">
    <testcase classname="foo" file="foo.py" line="3" name="test" time="0.001">
        <skipped message="expected test failure">xfail for some reason</skipped>
    </testcase>
    <testcase classname="foo" file="foo.py" line="8" name="test_ok" time="0.001"></testcase>
</testsuite>

Your PR generates:

<?xml version="1.0" encoding="utf-8"?>
<testsuite errors="0" failures="0" name="pytest" skipped="1" tests="2" time="0.074">
    <testcase classname="foo" file="foo.py" line="3" name="test" time="0.002">
        <skipped message="xfail for some reason" type="pytest.xfail"></skipped>
    </testcase>
    <testcase classname="foo" file="foo.py" line="8" name="test_ok" time="0.000"></testcase>
</testsuite>

The type property added to the skipped item does conform with the latest junit specification:

    <xs:element name="skipped">
        <xs:complexType mixed="true">
            <xs:attribute name="type" type="xs:string"/>
            <xs:attribute name="message" type="xs:string"/>
        </xs:complexType>
    </xs:element>

So I think we are good here. 👍 (created #5095 as a follow up btw)

@nicoddemus
Copy link
Member

Hmm although this can be considered a bug-fix, it does change how we produce the XML and might break custom scripts which process the file and expect what pytest already generates.

I think we should rebase this to features and change the change log as a new feature. What do you think @blueyed?

@blueyed
Copy link
Contributor

blueyed commented Apr 11, 2019

Yes, "features" sounds better.

@samueldg
You can rebase it, and force-push here, then change the base branch from the "Edit" button next to the PR title. Also rename the changelog file then, please.

@samueljsb
Copy link
Contributor Author

I'll sort that out now 👍

@samueljsb samueljsb changed the base branch from master to features April 11, 2019 21:23
@nicoddemus
Copy link
Member

Thanks a lot @samueljsb!

@nicoddemus nicoddemus merged commit 48ed437 into pytest-dev:features Apr 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants