Merge branch 'junit_stdout_err_on_error'

This commit is contained in:
Bruno Oliveira 2016-01-20 19:06:50 -02:00
commit 61c569f960
4 changed files with 34 additions and 0 deletions

View File

@ -35,6 +35,7 @@ Erik M. Bray
Florian Bruhin Florian Bruhin
Floris Bruynooghe Floris Bruynooghe
Gabriel Reis Gabriel Reis
Georgy Dyuldin
Graham Horler Graham Horler
Grig Gheorghiu Grig Gheorghiu
Guido Wesdorp Guido Wesdorp

View File

@ -26,6 +26,9 @@
- fix #628: fixed internal UnicodeDecodeError when doctests contain unicode. - fix #628: fixed internal UnicodeDecodeError when doctests contain unicode.
Thanks Jason R. Coombs for the report and Bruno Oliveira for the PR. Thanks Jason R. Coombs for the report and Bruno Oliveira for the PR.
- fix #1334: Add captured stdout to jUnit XML report on setup error.
Thanks Georgy Dyuldin for the PR.
2.8.5 2.8.5
----- -----

View File

@ -163,6 +163,7 @@ class _NodeReporter(object):
def append_error(self, report): def append_error(self, report):
self._add_simple( self._add_simple(
Junit.error, "test setup failure", report.longrepr) Junit.error, "test setup failure", report.longrepr)
self._write_captured_output(report)
def append_skipped(self, report): def append_skipped(self, report):
if hasattr(report, "wasxfail"): if hasattr(report, "wasxfail"):

View File

@ -419,6 +419,35 @@ class TestPython:
systemout = pnode.find_first_by_tag("system-err") systemout = pnode.find_first_by_tag("system-err")
assert "hello-stderr" in systemout.toxml() assert "hello-stderr" in systemout.toxml()
def test_setup_error_captures_stdout(self, testdir):
testdir.makepyfile("""
def pytest_funcarg__arg(request):
print('hello-stdout')
raise ValueError()
def test_function(arg):
pass
""")
result, dom = runandparse(testdir)
node = dom.find_first_by_tag("testsuite")
pnode = node.find_first_by_tag("testcase")
systemout = pnode.find_first_by_tag("system-out")
assert "hello-stdout" in systemout.toxml()
def test_setup_error_captures_stderr(self, testdir):
testdir.makepyfile("""
import sys
def pytest_funcarg__arg(request):
sys.stderr.write('hello-stderr')
raise ValueError()
def test_function(arg):
pass
""")
result, dom = runandparse(testdir)
node = dom.find_first_by_tag("testsuite")
pnode = node.find_first_by_tag("testcase")
systemout = pnode.find_first_by_tag("system-err")
assert "hello-stderr" in systemout.toxml()
def test_mangle_testnames(): def test_mangle_testnames():
from _pytest.junitxml import mangle_testnames from _pytest.junitxml import mangle_testnames