Merge pull request #4353 from blueyed/test_fileimport

tests: test_fileimport: improve reporting on failure
This commit is contained in:
Bruno Oliveira 2018-11-09 08:32:49 -02:00 committed by GitHub
commit e00f3a2fb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 4 deletions

View File

@ -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)
)