Merge pull request #2315 from RonnyPfannschmidt/namespace-hook

remove pytest internal usage of the namespace hook
This commit is contained in:
Bruno Oliveira
2017-04-21 16:24:20 -03:00
committed by GitHub
20 changed files with 309 additions and 212 deletions

25
testing/test_modimport.py Normal file
View File

@@ -0,0 +1,25 @@
import py
import subprocess
import sys
import pytest
import _pytest
MODSET = [
x for x in py.path.local(_pytest.__file__).dirpath().visit('*.py')
if x.purebasename != '__init__'
]
@pytest.mark.parametrize('modfile', MODSET, ids=lambda x: x.purebasename)
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
res = subprocess.call([
sys.executable,
'-c', 'import sys, py; py.path.local(sys.argv[1]).pyimport()',
modfile.strpath,
])
if res:
pytest.fail("command result %s" % res)