From b494d3d1c11e94a3b2d83250e031205de53d8394 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 9 Nov 2018 01:16:55 +0100 Subject: [PATCH] tests: test_fileimport: improve reporting on failure --- testing/test_modimport.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/testing/test_modimport.py b/testing/test_modimport.py index 64e9d7261..cb5f5ccd3 100644 --- a/testing/test_modimport.py +++ b/testing/test_modimport.py @@ -19,13 +19,19 @@ def test_fileimport(modfile): # without needing the pytest namespace being set # this is critical for the initialization of xdist - res = subprocess.call( + p = subprocess.Popen( [ sys.executable, "-c", "import sys, py; py.path.local(sys.argv[1]).pyimport()", modfile.strpath, - ] + ], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, ) - if res: - pytest.fail("command result %s" % res) + (out, err) = p.communicate() + if p.returncode != 0: + pytest.fail( + "importing %s failed (exitcode %d): out=%r, err=%r" + % (modfile, p.returncode, out, err) + )