def test_zipimport_hook(pytester: Pytester) -> None:
    """Test package loader is being used correctly (see #1837)."""
    zipapp = pytest.importorskip("zipapp")
    pytester.path.joinpath("app").mkdir()
    pytester.makepyfile(
        **{
            "app/foo.py": """
            import pytest
            def main():
                pytest.main(['--pyargs', 'foo'])
        """
        }
    )
    target = pytester.path.joinpath("foo.zip")
    zipapp.create_archive(
        str(pytester.path.joinpath("app")), str(target), main="foo:main"
    )
    result = pytester.runpython(target)
    assert result.ret == 0
    result.stderr.fnmatch_lines(["*not found*foo*"])
    result.stdout.no_fnmatch_line("*INTERNALERROR>*")
Test package loader is being used correctly (see #1837).
testing/acceptance_test.py