Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/13695.contrib.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Flush `stdout` and `stderr` in `Pytester.run` to avoid truncated outputs in `test_faulthandler.py::test_timeout` on CI -- by :user:`ogrisel`.
3 changes: 2 additions & 1 deletion src/_pytest/pytester.py
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,6 @@ def run(
stdin=stdin,
stdout=f1,
stderr=f2,
close_fds=(sys.platform != "win32"),
)
if popen.stdin is not None:
popen.stdin.close()
Expand All @@ -1443,6 +1442,8 @@ def handle_timeout() -> None:
ret = popen.wait(timeout)
except subprocess.TimeoutExpired:
handle_timeout()
f1.flush()
f2.flush()

with p1.open(encoding="utf8") as f1, p2.open(encoding="utf8") as f2:
out = f1.read().splitlines()
Expand Down
9 changes: 8 additions & 1 deletion testing/test_faulthandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import annotations

import io
import os
import sys

from _pytest.pytester import Pytester
Expand Down Expand Up @@ -76,7 +77,13 @@ def test_disabled():
"enabled",
[
pytest.param(
True, marks=pytest.mark.skip(reason="sometimes crashes on CI (#7022)")
True,
marks=pytest.mark.skipif(
"CI" in os.environ
and sys.platform == "linux"
and sys.version_info >= (3, 14),
reason="sometimes crashes on CI because of truncated outputs (#7022)",
),
),
False,
],
Expand Down
4 changes: 2 additions & 2 deletions testing/test_terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2250,8 +2250,8 @@ def test_times_multiline(
output.stdout.re_match_lines(
[
r"test_bar.py ...................",
r"........... \s+ \d{1,3}[\.[a-z\ ]{1,2}\d{0,3}\w{1,2}$",
r"test_foo.py \.{5} \s+ \d{1,3}[\.[a-z\ ]{1,2}\d{0,3}\w{1,2}$",
r"........... \s+ \d{1,4}[\.[a-z\ ]{1,2}\d{0,3}\w{1,2}$",
r"test_foo.py \.{5} \s+ \d{1,4}[\.[a-z\ ]{1,2}\d{0,3}\w{1,2}$",
],
consecutive=True,
)
Expand Down
Loading