Skip to content

Commit e00f3a2

Browse files
authored
Merge pull request #4353 from blueyed/test_fileimport
tests: test_fileimport: improve reporting on failure
2 parents afaad2f + b494d3d commit e00f3a2

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

testing/test_modimport.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,19 @@ def test_fileimport(modfile):
1919
# without needing the pytest namespace being set
2020
# this is critical for the initialization of xdist
2121

22-
res = subprocess.call(
22+
p = subprocess.Popen(
2323
[
2424
sys.executable,
2525
"-c",
2626
"import sys, py; py.path.local(sys.argv[1]).pyimport()",
2727
modfile.strpath,
28-
]
28+
],
29+
stdout=subprocess.PIPE,
30+
stderr=subprocess.PIPE,
2931
)
30-
if res:
31-
pytest.fail("command result %s" % res)
32+
(out, err) = p.communicate()
33+
if p.returncode != 0:
34+
pytest.fail(
35+
"importing %s failed (exitcode %d): out=%r, err=%r"
36+
% (modfile, p.returncode, out, err)
37+
)

0 commit comments

Comments
 (0)