Skip to content

Commit 9573103

Browse files
authored
Merge pull request #29890 from thomashopkins32/capture-subprocess-test-errors
Show subprocess stdout and stderr on pytest failure
2 parents 1e20a86 + 126507f commit 9573103

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/matplotlib/testing/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,16 @@ def subprocess_run_for_testing(command, env=None, timeout=60, stdout=None,
105105
import pytest
106106
pytest.xfail("Fork failure")
107107
raise
108+
except subprocess.CalledProcessError as e:
109+
if e.stdout:
110+
_log.error(f"Subprocess output:\n{e.stdout}")
111+
if e.stderr:
112+
_log.error(f"Subprocess error:\n{e.stderr}")
113+
raise e
114+
if proc.stdout:
115+
_log.debug(f"Subprocess output:\n{proc.stdout}")
116+
if proc.stderr:
117+
_log.debug(f"Subprocess error:\n{proc.stderr}")
108118
return proc
109119

110120

0 commit comments

Comments
 (0)