test_ok1/testing/test_modimport.py

30 lines
721 B
Python
Raw Normal View History

2017-03-16 01:11:19 +08:00
import py
import subprocess
import sys
import pytest
import _pytest
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):
# this test ensures all internal packages can import
# without needing the pytest namespace being set
# this is critical for the initialization of xdist
2018-05-23 22:48:46 +08:00
res = subprocess.call(
[
sys.executable,
"-c",
"import sys, py; py.path.local(sys.argv[1]).pyimport()",
modfile.strpath,
]
)
2017-03-16 01:11:19 +08:00
if res:
pytest.fail("command result %s" % res)