Add acceptance test for module loader

Related to #1837
This commit is contained in:
Bruno Oliveira 2016-08-22 17:54:17 -03:00
parent 678750c8f8
commit 6a8160b318
1 changed files with 18 additions and 0 deletions

View File

@ -763,3 +763,21 @@ class TestDurationWithFixture:
* call *test_1* * call *test_1*
""") """)
def test_zipimport_hook(testdir, tmpdir):
"""Test package loader is being used correctly (see #1837)."""
zipapp = pytest.importorskip('zipapp')
testdir.tmpdir.join('app').ensure(dir=1)
testdir.makepyfile(**{
'app/foo.py': """
import pytest
def main():
pytest.main(['--pyarg', 'foo'])
""",
})
target = tmpdir.join('foo.zip')
zipapp.create_archive(str(testdir.tmpdir.join('app')), str(target), main='foo:main')
result = testdir.runpython(target)
assert result.ret == 0
result.stderr.fnmatch_lines(['*not found*foo*'])
assert 'INTERNALERROR>' not in result.stdout.str()