From 6a8160b3181f6f0fd0bc8afa40eca0a8913d4c29 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 22 Aug 2016 17:54:17 -0300 Subject: [PATCH] Add acceptance test for module loader Related to #1837 --- testing/acceptance_test.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 82b131dccaf..b03f7fe4c36 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -763,3 +763,21 @@ def test_setup_function(self, testdir): * 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()