Skip to content

Commit

Permalink
Merge pull request #1799 from cryporchild/junitxml-tests-tally-fix
Browse files Browse the repository at this point in the history
Fix #1798 to include errors in total tests in junit xml output.
  • Loading branch information
nicoddemus authored Aug 8, 2016
2 parents ac5c39e + c4d9c7e commit 34925a3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Carl Friedrich Bolz
Charles Cloud
Charnjit SiNGH (CCSJ)
Chris Lamb
Christian Boelsen
Christian Theunert
Christian Tismer
Christopher Gilling
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
* Fixed scope overriding inside metafunc.parametrize (`#634`_).
Thanks to `@Stranger6667`_ for the PR.

* Fixed the total tests tally in junit xml output (`#1798`_).
Thanks to `@cryporchild`_ for the PR.

*

*
Expand All @@ -85,6 +88,7 @@
.. _#1597: https://github.com/pytest-dev/pytest/pull/1597
.. _#1605: https://github.com/pytest-dev/pytest/issues/1605
.. _#1626: https://github.com/pytest-dev/pytest/pull/1626
.. _#1798: https://github.com/pytest-dev/pytest/pull/1798
.. _#460: https://github.com/pytest-dev/pytest/pull/460
.. _#634: https://github.com/pytest-dev/pytest/issues/634
.. _#717: https://github.com/pytest-dev/pytest/issues/717
Expand All @@ -93,6 +97,7 @@
.. _@bagerard: https://github.com/bagerard
.. _@BeyondEvil: https://github.com/BeyondEvil
.. _@blueyed: https://github.com/blueyed
.. _@cryporchild: https://github.com/cryporchild
.. _@davehunt: https://github.com/davehunt
.. _@DRMacIver: https://github.com/DRMacIver
.. _@eolo999: https://github.com/eolo999
Expand Down
2 changes: 1 addition & 1 deletion _pytest/junitxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def pytest_sessionfinish(self):
suite_stop_time = time.time()
suite_time_delta = suite_stop_time - self.suite_start_time

numtests = self.stats['passed'] + self.stats['failure'] + self.stats['skipped']
numtests = self.stats['passed'] + self.stats['failure'] + self.stats['skipped'] + self.stats['error']

logfile.write('<?xml version="1.0" encoding="utf-8"?>')
logfile.write(Junit.testsuite(
Expand Down
27 changes: 24 additions & 3 deletions testing/test_junitxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,27 @@ def test_xpass():
node = dom.find_first_by_tag("testsuite")
node.assert_attr(name="pytest", errors=0, failures=1, skips=3, tests=5)

def test_summing_simple_with_errors(self, testdir):
testdir.makepyfile("""
import pytest
@pytest.fixture
def fixture():
raise Exception()
def test_pass():
pass
def test_fail():
assert 0
def test_error(fixture):
pass
@pytest.mark.xfail
def test_xpass():
assert 1
""")
result, dom = runandparse(testdir)
assert result.ret
node = dom.find_first_by_tag("testsuite")
node.assert_attr(name="pytest", errors=1, failures=1, skips=1, tests=4)

def test_timing_function(self, testdir):
testdir.makepyfile("""
import time, pytest
Expand All @@ -128,7 +149,7 @@ def test_function(arg):
result, dom = runandparse(testdir)
assert result.ret
node = dom.find_first_by_tag("testsuite")
node.assert_attr(errors=1, tests=0)
node.assert_attr(errors=1, tests=1)
tnode = node.find_first_by_tag("testcase")
tnode.assert_attr(
file="test_setup_error.py",
Expand Down Expand Up @@ -195,7 +216,7 @@ def test_internal_error(self, testdir):
result, dom = runandparse(testdir)
assert result.ret
node = dom.find_first_by_tag("testsuite")
node.assert_attr(errors=1, tests=0)
node.assert_attr(errors=1, tests=1)
tnode = node.find_first_by_tag("testcase")
tnode.assert_attr(classname="pytest", name="internal")
fnode = tnode.find_first_by_tag("error")
Expand Down Expand Up @@ -341,7 +362,7 @@ def test_collect_error(self, testdir):
result, dom = runandparse(testdir)
assert result.ret
node = dom.find_first_by_tag("testsuite")
node.assert_attr(errors=1, tests=0)
node.assert_attr(errors=1, tests=1)
tnode = node.find_first_by_tag("testcase")
tnode.assert_attr(
file="test_collect_error.py",
Expand Down

0 comments on commit 34925a3

Please sign in to comment.