Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4bfeef6

Browse files
authored
Merge pull request #6747 from janschulz/better_subprocess_errors
Also output the actual error on svg backend tests using subprocess
2 parents cf24e05 + 45a1d22 commit 4bfeef6

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

lib/matplotlib/tests/test_backend_svg.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,25 @@ def _test_determinism_save(filename, usetex):
153153
def _test_determinism(filename, usetex):
154154
import os
155155
import sys
156-
from subprocess import check_call
156+
from subprocess import check_output, STDOUT, CalledProcessError
157157
from nose.tools import assert_equal
158158
plots = []
159159
for i in range(3):
160-
check_call([sys.executable, '-R', '-c',
161-
'import matplotlib; '
162-
'matplotlib.use("svg"); '
163-
'from matplotlib.tests.test_backend_svg '
164-
'import _test_determinism_save;'
165-
'_test_determinism_save(%r, %r)' % (filename, usetex)])
160+
# Using check_output and setting stderr to STDOUT will capture the real
161+
# problem in the output property of the exception
162+
try:
163+
check_output([sys.executable, '-R', '-c',
164+
'import matplotlib; '
165+
'matplotlib.use("svg"); '
166+
'from matplotlib.tests.test_backend_svg '
167+
'import _test_determinism_save;'
168+
'_test_determinism_save(%r, %r)' % (filename, usetex)],
169+
stderr=STDOUT)
170+
except CalledProcessError as e:
171+
# it's easier to use utf8 and ask for forgiveness than try to figure
172+
# out what the current console has as an encoding :-/
173+
print(e.output.decode(encoding="utf-8", errors="ignore"))
174+
raise e
166175
with open(filename, 'rb') as fd:
167176
plots.append(fd.read())
168177
os.unlink(filename)

0 commit comments

Comments
 (0)