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

xunittest.Parser() assertion error when a test case error out #13

Open
tafify opened this issue Nov 20, 2018 · 0 comments
Open

xunittest.Parser() assertion error when a test case error out #13

tafify opened this issue Nov 20, 2018 · 0 comments

Comments

@tafify
Copy link

tafify commented Nov 20, 2018

parser for the following junit test case results xml, will produce an AssertionError

<?xml version="1.0" encoding="utf-8"?>
<testsuite errors="1" failures="147" name="pytest" skips="1" tests="149" time="6.702">
  <testcase classname="tests.functional.test_tasks" file="tests/functional/test_case.py" line="164" name="test_query" time="0.5505721569061279">
    <system-out>
    </system-out>
  </testcase>
  <testcase classname="tests.functional.test_tasks" file="tests/functional/test_case.py" line="424" name="TEST_CASE" time="0.0059661865234375">
    <error message="test teardown failure"></error>
    <system-out>
    </system-out>
  </testcase>
</testsuite>

The AssertionError is;

  File "/home/jenkins/.pyenv/versions/3.6.3/lib/python3.6/site-packages/xunitparser.py", line 141, in parse
    return self.parse_root(root)
  File "/home/jenkins/.pyenv/versions/3.6.3/lib/python3.6/site-packages/xunitparser.py", line 163, in parse_root
    assert len(list(ts)) == int(root.attrib['tests'])
AssertionError

That is because the tests count is off by errors count of tests. The fix for that assert line should be

        if 'tests' in root.attrib:
            # this is a fix for xunitparser AssertionError out when a test errors out
            assert len(list(ts)) == int(root.attrib['tests']) - int(root.attrib.get('errors', '0'))
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

No branches or pull requests

1 participant