Skip to content

Commit 48e5934

Browse files
committed
TST: Catch fork failures and mark them as xfail instead of fail.
Not a pass, but not the fault of the test. TST,BUG: Move pytest import to just before its use. Hopefully this fixes the doc builds.
1 parent 66349ef commit 48e5934

File tree

2 files changed

+35
-15
lines changed

2 files changed

+35
-15
lines changed

lib/matplotlib/testing/__init__.py

+17-10
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,23 @@ def subprocess_run_helper(func, *args, timeout, extra_env=None):
6666
"""
6767
target = func.__name__
6868
module = func.__module__
69-
proc = subprocess.run(
70-
[sys.executable,
71-
"-c",
72-
f"from {module} import {target}; {target}()",
73-
*args],
74-
env={**os.environ, "SOURCE_DATE_EPOCH": "0", **(extra_env or {})},
75-
timeout=timeout, check=True,
76-
stdout=subprocess.PIPE,
77-
stderr=subprocess.PIPE,
78-
universal_newlines=True)
69+
try:
70+
proc = subprocess.run(
71+
[sys.executable,
72+
"-c",
73+
f"from {module} import {target}; {target}()",
74+
*args],
75+
env={**os.environ, "SOURCE_DATE_EPOCH": "0", **(extra_env or {})},
76+
timeout=timeout, check=True,
77+
stdout=subprocess.PIPE,
78+
stderr=subprocess.PIPE,
79+
universal_newlines=True)
80+
except BlockingIOError:
81+
if sys.platform == "cygwin":
82+
import pytest
83+
pytest.xfail("Fork failure")
84+
else:
85+
raise
7986
return proc
8087

8188

lib/matplotlib/tests/test_sphinxext.py

+18-5
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,16 @@ def test_tinypages(tmp_path):
2727
# On CI, gcov emits warnings (due to agg headers being included with the
2828
# same name in multiple extension modules -- but we don't care about their
2929
# coverage anyways); hide them using GCOV_ERROR_FILE.
30-
proc = Popen(
31-
cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True,
32-
env={**os.environ, "MPLBACKEND": "", "GCOV_ERROR_FILE": os.devnull})
30+
try:
31+
proc = Popen(
32+
cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True,
33+
env={**os.environ, "MPLBACKEND": "", "GCOV_ERROR_FILE": os.devnull}
34+
)
35+
except BlockingIOError:
36+
if sys.platform == "cygwin":
37+
pytest.xfail("Fork failure")
38+
else:
39+
raise
3340
out, err = proc.communicate()
3441

3542
# Build the pages with warnings turned into errors
@@ -166,8 +173,14 @@ def build_sphinx_html(tmp_path, doctree_dir, html_dir, extra_args=None):
166173
extra_args = [] if extra_args is None else extra_args
167174
cmd = [sys.executable, '-msphinx', '-W', '-b', 'html',
168175
'-d', str(doctree_dir), str(tmp_path), str(html_dir), *extra_args]
169-
proc = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True,
170-
env={**os.environ, "MPLBACKEND": ""})
176+
try:
177+
proc = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True,
178+
env={**os.environ, "MPLBACKEND": ""})
179+
except BlockingIOError:
180+
if sys.platform == "cygwin":
181+
pytest.xfail("Fork failure")
182+
else:
183+
raise
171184
out, err = proc.communicate()
172185

173186
assert proc.returncode == 0, \

0 commit comments

Comments
 (0)