[4.6] Bugfix 5430 pass logs to junit report (#6338)
[4.6] Bugfix 5430 pass logs to junit report
This commit is contained in:
commit
51fd451dc9
1
AUTHORS
1
AUTHORS
|
@ -58,6 +58,7 @@ Christian Theunert
|
||||||
Christian Tismer
|
Christian Tismer
|
||||||
Christopher Gilling
|
Christopher Gilling
|
||||||
Christopher Dignam
|
Christopher Dignam
|
||||||
|
Claudio Madotto
|
||||||
CrazyMerlyn
|
CrazyMerlyn
|
||||||
Cyrus Maden
|
Cyrus Maden
|
||||||
Damian Skrzypczak
|
Damian Skrzypczak
|
||||||
|
|
|
@ -48,12 +48,6 @@ jobs:
|
||||||
# pypy3:
|
# pypy3:
|
||||||
# python.version: 'pypy3'
|
# python.version: 'pypy3'
|
||||||
# tox.env: 'pypy3'
|
# tox.env: 'pypy3'
|
||||||
py34-xdist:
|
|
||||||
python.version: '3.4'
|
|
||||||
tox.env: 'py34-xdist'
|
|
||||||
# Coverage for:
|
|
||||||
# - _pytest.compat._bytes_to_ascii
|
|
||||||
PYTEST_COVERAGE: '1'
|
|
||||||
py35-xdist:
|
py35-xdist:
|
||||||
python.version: '3.5'
|
python.version: '3.5'
|
||||||
tox.env: 'py35-xdist'
|
tox.env: 'py35-xdist'
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
junitxml: Logs for failed test are now passed to junit report in case the test fails during call phase.
|
|
@ -597,6 +597,8 @@ class LogXML(object):
|
||||||
if report.when == "call":
|
if report.when == "call":
|
||||||
reporter.append_failure(report)
|
reporter.append_failure(report)
|
||||||
self.open_reports.append(report)
|
self.open_reports.append(report)
|
||||||
|
if not self.log_passing_tests:
|
||||||
|
reporter.write_captured_output(report)
|
||||||
else:
|
else:
|
||||||
reporter.append_error(report)
|
reporter.append_error(report)
|
||||||
elif report.skipped:
|
elif report.skipped:
|
||||||
|
|
|
@ -1409,3 +1409,39 @@ def test_logging_passing_tests_disabled_does_not_log_test_output(testdir):
|
||||||
node = dom.find_first_by_tag("testcase")
|
node = dom.find_first_by_tag("testcase")
|
||||||
assert len(node.find_by_tag("system-err")) == 0
|
assert len(node.find_by_tag("system-err")) == 0
|
||||||
assert len(node.find_by_tag("system-out")) == 0
|
assert len(node.find_by_tag("system-out")) == 0
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("junit_logging", ["no", "system-out", "system-err"])
|
||||||
|
def test_logging_passing_tests_disabled_logs_output_for_failing_test_issue5430(
|
||||||
|
testdir, junit_logging
|
||||||
|
):
|
||||||
|
testdir.makeini(
|
||||||
|
"""
|
||||||
|
[pytest]
|
||||||
|
junit_log_passing_tests=False
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
testdir.makepyfile(
|
||||||
|
"""
|
||||||
|
import pytest
|
||||||
|
import logging
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def test_func():
|
||||||
|
logging.warning('hello')
|
||||||
|
assert 0
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
result, dom = runandparse(testdir, "-o", "junit_logging=%s" % junit_logging)
|
||||||
|
assert result.ret == 1
|
||||||
|
node = dom.find_first_by_tag("testcase")
|
||||||
|
if junit_logging == "system-out":
|
||||||
|
assert len(node.find_by_tag("system-err")) == 0
|
||||||
|
assert len(node.find_by_tag("system-out")) == 1
|
||||||
|
elif junit_logging == "system-err":
|
||||||
|
assert len(node.find_by_tag("system-err")) == 1
|
||||||
|
assert len(node.find_by_tag("system-out")) == 0
|
||||||
|
else:
|
||||||
|
assert junit_logging == "no"
|
||||||
|
assert len(node.find_by_tag("system-err")) == 0
|
||||||
|
assert len(node.find_by_tag("system-out")) == 0
|
||||||
|
|
Loading…
Reference in New Issue