def test_zipimport_hook(testdir, tmpdir):
 zipapp = pytest.importorskip('zipapp')
 testdir.tmpdir.join('app').ensure(dir=1)
 testdir.makepyfile(**{'app/foo.py': "\n            import pytest\n            def main():\n                pytest.main(['--pyarg', 'foo'])\n        "})
 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())

def test_zipimport_hook ( testdir , tmpdir ) : zipapp = pytest . importorskip ( 'zipapp' ) testdir . tmpdir . join ( 'app' ) . ensure ( dir = 1 ) testdir . makepyfile ( ** { 'app/foo.py' : "\n            import pytest\n            def main():\n                pytest.main(['--pyarg', 'foo'])\n        " } ) 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 ( ) )
test package loader is being used correctly .