Skip to content

Commit 19f99fd

Browse files
authored
Merge branch 'master' into loadsched-initial-batch
2 parents 562c6da + e407a33 commit 19f99fd

File tree

5 files changed

+55
-0
lines changed

5 files changed

+55
-0
lines changed

changelog/813.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Cancel shutdown when a crashed worker is restarted.

docs/known-limitations.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,12 @@ Some solutions:
5050
@pytest.mark.parametrize("param", sorted({"a", "b"}))
5151
def test_pytest_parametrize_unordered(param):
5252
pass
53+
54+
Output (stdout and stderr) from workers
55+
---------------------------------------
56+
57+
The ``-s``/``--capture=no`` option is meant to disable pytest capture, so users can then see stdout and stderr output in the terminal from tests and application code in real time.
58+
59+
However this option does not work with ``pytest-xdist`` because `execnet <https://github.com/pytest-dev/execnet>`__ the underlying library used for communication between master and workers, does not support transferring stdout/stderr from workers.
60+
61+
Currenlty there are no plans ot support this in ``pytest-xdist``.

src/xdist/dsession.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ def worker_errordown(self, node, error):
225225
self.triggershutdown()
226226
else:
227227
self.report_line("\nreplacing crashed worker %s" % node.gateway.id)
228+
self.shuttingdown = False
228229
self._clone_node(node)
229230
self._active_nodes.remove(node)
230231

testing/acceptance_test.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,3 +1543,22 @@ def test_get_xdist_worker_id(self, fake_request) -> None:
15431543
assert xdist.get_xdist_worker_id(fake_request) == "gw5"
15441544
del fake_request.config.workerinput
15451545
assert xdist.get_xdist_worker_id(fake_request) == "master"
1546+
1547+
1548+
def test_collection_crash(testdir):
1549+
p1 = testdir.makepyfile(
1550+
"""
1551+
assert 0
1552+
"""
1553+
)
1554+
result = testdir.runpytest(p1, "-n1")
1555+
assert result.ret == 1
1556+
result.stdout.fnmatch_lines(
1557+
[
1558+
"gw0 I",
1559+
"gw0 [[]0[]]",
1560+
"*_ ERROR collecting test_collection_crash.py _*",
1561+
"E assert 0",
1562+
"*= 1 error in *",
1563+
]
1564+
)

testing/test_newhooks.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,28 @@ def pytest_handlecrashitem(crashitem, report, sched):
9494
res = pytester.runpytest("-n2", "-s")
9595
res.stdout.fnmatch_lines_random(["*HOOK: pytest_handlecrashitem"])
9696
res.stdout.fnmatch_lines(["*3 passed*"])
97+
98+
def test_handlecrashitem_one(self, pytester: pytest.Pytester) -> None:
99+
"""Test pytest_handlecrashitem hook with just one test."""
100+
pytester.makeconftest(
101+
"""
102+
test_runs = 0
103+
104+
def pytest_handlecrashitem(crashitem, report, sched):
105+
global test_runs
106+
107+
if test_runs == 0:
108+
sched.mark_test_pending(crashitem)
109+
test_runs = 1
110+
else:
111+
print("HOOK: pytest_handlecrashitem")
112+
"""
113+
)
114+
res = pytester.runpytest("-n1", "-s", "-k", "test_b")
115+
res.stdout.fnmatch_lines_random(["*HOOK: pytest_handlecrashitem"])
116+
res.stdout.fnmatch_lines(
117+
[
118+
"FAILED test_handlecrashitem_one.py::test_b",
119+
"FAILED test_handlecrashitem_one.py::test_b",
120+
]
121+
)

0 commit comments

Comments
 (0)