fix pytest/xdist issue485 (also depends on py-1.4.21.dev1):
attach stdout/stderr on --boxed processes that die.
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
XXX
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
- fix pytest/xdist issue485 (also depends on py-1.4.21.dev1):
|
||||||
|
attach stdout/stderr on --boxed processes that die.
|
||||||
|
|
||||||
1.10
|
1.10
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -2,7 +2,7 @@ from setuptools import setup
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="pytest-xdist",
|
name="pytest-xdist",
|
||||||
version='1.10',
|
version='1.11.dev1',
|
||||||
description='py.test xdist plugin for distributed testing and loop-on-failing modes',
|
description='py.test xdist plugin for distributed testing and loop-on-failing modes',
|
||||||
long_description=open('README.txt').read(),
|
long_description=open('README.txt').read(),
|
||||||
license='MIT',
|
license='MIT',
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
import py
|
import pytest
|
||||||
|
import os
|
||||||
|
|
||||||
@py.test.mark.skipif("not hasattr(os, 'fork')")
|
needsfork = pytest.mark.skipif(not hasattr(os, "fork"),
|
||||||
|
reason="os.fork required")
|
||||||
|
|
||||||
|
@needsfork
|
||||||
def test_functional_boxed(testdir):
|
def test_functional_boxed(testdir):
|
||||||
p1 = testdir.makepyfile("""
|
p1 = testdir.makepyfile("""
|
||||||
import os
|
import os
|
||||||
@@ -13,12 +17,32 @@ def test_functional_boxed(testdir):
|
|||||||
"*1 failed*"
|
"*1 failed*"
|
||||||
])
|
])
|
||||||
|
|
||||||
|
@needsfork
|
||||||
|
def test_functional_boxed_stdout(testdir):
|
||||||
|
p1 = testdir.makepyfile("""
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
def test_function():
|
||||||
|
sys.stdout.write("hello\\n")
|
||||||
|
sys.stderr.write("world\\n")
|
||||||
|
os.kill(os.getpid(), 15)
|
||||||
|
""")
|
||||||
|
result = testdir.runpytest(p1, "--boxed")
|
||||||
|
result.stdout.fnmatch_lines("""
|
||||||
|
*CRASHED*
|
||||||
|
*stdout*
|
||||||
|
hello
|
||||||
|
*stderr*
|
||||||
|
world
|
||||||
|
*1 failed*
|
||||||
|
""")
|
||||||
|
|
||||||
class TestOptionEffects:
|
class TestOptionEffects:
|
||||||
def test_boxed_option_default(self, testdir):
|
def test_boxed_option_default(self, testdir):
|
||||||
tmpdir = testdir.tmpdir.ensure("subdir", dir=1)
|
tmpdir = testdir.tmpdir.ensure("subdir", dir=1)
|
||||||
config = testdir.parseconfig()
|
config = testdir.parseconfig()
|
||||||
assert not config.option.boxed
|
assert not config.option.boxed
|
||||||
py.test.importorskip("execnet")
|
pytest.importorskip("execnet")
|
||||||
config = testdir.parseconfig('-d', tmpdir)
|
config = testdir.parseconfig('-d', tmpdir)
|
||||||
assert not config.option.boxed
|
assert not config.option.boxed
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
#
|
#
|
||||||
__version__ = '1.10'
|
__version__ = '1.11.dev1'
|
||||||
|
|||||||
@@ -118,10 +118,14 @@ def forked_run_report(item):
|
|||||||
|
|
||||||
def report_process_crash(item, result):
|
def report_process_crash(item, result):
|
||||||
path, lineno = item._getfslineno()
|
path, lineno = item._getfslineno()
|
||||||
info = "%s:%s: running the test CRASHED with signal %d" %(
|
info = ("%s:%s: running the test CRASHED with signal %d" %
|
||||||
path, lineno, result.signal)
|
(path, lineno, result.signal))
|
||||||
from _pytest import runner
|
from _pytest import runner
|
||||||
call = runner.CallInfo(lambda: 0/0, "???")
|
call = runner.CallInfo(lambda: 0/0, "???")
|
||||||
call.excinfo = info
|
call.excinfo = info
|
||||||
rep = runner.pytest_runtest_makereport(item, call)
|
rep = runner.pytest_runtest_makereport(item, call)
|
||||||
|
if result.out:
|
||||||
|
rep.sections.append(("captured stdout", result.out))
|
||||||
|
if result.err:
|
||||||
|
rep.sections.append(("captured stderr", result.err))
|
||||||
return rep
|
return rep
|
||||||
|
|||||||
Reference in New Issue
Block a user