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

junitxml: Fix double system-out tags per testcase #2271

Merged
merged 1 commit into from
Feb 22, 2017

Conversation

KKoukiou
Copy link
Contributor

In the xml report we now have two occurrences for the system-out tag if
the testcase writes to stdout both on call and teardown and fails in
teardown.
This behaviour is against the xsd.
This patch makes sure that the system-out section exists only once per testcase.

How to reproduce:

@pytest.fixture(scope="function")
def setup_test(request):
    print("I am in setup")
    yield
    print("I am in teardown")
    raise Exception("test teardown Exception!")
    
def test_1(setup_test):
    print("I am in call")

Gives output:

<?xml version="1.0" encoding="utf-8"?>
<testsuite errors="1" failures="0" name="pytest" skips="0" tests="2" time="0.017">
  <testcase classname="test.test2" file="test/test2.py" line="11" name="test_1" time="0.000563859939575">
    <system-out>
    I am in setup
    I am in call
    </system-out>
    <error message="test teardown failure">request = &lt;SubRequest 'setup_test' for &lt;Function 'test_1'&gt;&gt;

    @pytest.fixture(scope="function")
    def setup_test(request):
        print("I am in setup")
        yield
        print("I am in teardown")
&gt;       raise Exception("test teardown Exception!")
E       Exception: test teardown Exception!

../../test/test2.py:9: Exception
    </error>
    <system-out>
    I am in setup
    I am in call
    I am in teardown
    </system-out>
  </testcase>
</testsuite>

Notice int he above output the double occurrence of the system-out tag.

@KKoukiou
Copy link
Contributor Author

The reason I noticed this problem is the following: we use Jenkins Junit plugin to parse the xml file and show the TestReport in Jenkins. The former when it encounters two system-out tags in a testcase element, it accepts the first and discards the second tag. As a result we lose the stdout prints from teardown.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.0008%) to 92.708% when pulling 3a70140 on KKoukiou:double-tag into 6680cb9 on pytest-dev:master.

In the xml report we now have two occurences for the system-out tag if
the testcase writes to stdout both on call and teardown and fails in
teardown.
This behaviour is against the xsd.
This patch makes sure that the system-out section exists only
once per testcase.
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.0008%) to 92.708% when pulling d3a6be4 on KKoukiou:double-tag into 6680cb9 on pytest-dev:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.0008%) to 92.708% when pulling d3a6be4 on KKoukiou:double-tag into 6680cb9 on pytest-dev:master.

@RonnyPfannschmidt RonnyPfannschmidt merged commit 0a89db2 into pytest-dev:master Feb 22, 2017
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.0008%) to 92.708% when pulling d3a6be4 on KKoukiou:double-tag into 6680cb9 on pytest-dev:master.

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.

4 participants