2017-03-16 01:11:19 +08:00
|
|
|
import subprocess
|
|
|
|
import sys
|
2018-10-25 15:01:29 +08:00
|
|
|
|
|
|
|
import py
|
|
|
|
|
2017-03-16 01:11:19 +08:00
|
|
|
import _pytest
|
2018-10-25 15:01:29 +08:00
|
|
|
import pytest
|
2017-03-16 01:11:19 +08:00
|
|
|
|
|
|
|
MODSET = [
|
2018-05-23 22:48:46 +08:00
|
|
|
x
|
|
|
|
for x in py.path.local(_pytest.__file__).dirpath().visit("*.py")
|
|
|
|
if x.purebasename != "__init__"
|
2017-03-16 01:11:19 +08:00
|
|
|
]
|
|
|
|
|
|
|
|
|
2018-05-23 22:48:46 +08:00
|
|
|
@pytest.mark.parametrize("modfile", MODSET, ids=lambda x: x.purebasename)
|
2017-03-16 01:11:19 +08:00
|
|
|
def test_fileimport(modfile):
|
2017-03-16 01:26:01 +08:00
|
|
|
# this test ensures all internal packages can import
|
|
|
|
# without needing the pytest namespace being set
|
|
|
|
# this is critical for the initialization of xdist
|
|
|
|
|
2018-11-09 08:16:55 +08:00
|
|
|
p = subprocess.Popen(
|
2018-05-23 22:48:46 +08:00
|
|
|
[
|
|
|
|
sys.executable,
|
|
|
|
"-c",
|
|
|
|
"import sys, py; py.path.local(sys.argv[1]).pyimport()",
|
|
|
|
modfile.strpath,
|
2018-11-09 08:16:55 +08:00
|
|
|
],
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
stderr=subprocess.PIPE,
|
2018-05-23 22:48:46 +08:00
|
|
|
)
|
2018-11-09 08:16:55 +08:00
|
|
|
(out, err) = p.communicate()
|
2019-03-23 00:16:08 +08:00
|
|
|
assert p.returncode == 0, "importing %s failed (exitcode %d): out=%r, err=%r" % (
|
|
|
|
modfile,
|
|
|
|
p.returncode,
|
|
|
|
out,
|
|
|
|
err,
|
|
|
|
)
|