MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_zipimport_hook

Function test_zipimport_hook

testing/acceptance_test.py:962–982  ·  view source on GitHub ↗

Test package loader is being used correctly (see #1837).

(pytester: Pytester)

Source from the content-addressed store, hash-verified

960
961
962def test_zipimport_hook(pytester: Pytester) -> None:
963 """Test package loader is being used correctly (see #1837)."""
964 zipapp = pytest.importorskip("zipapp")
965 pytester.path.joinpath("app").mkdir()
966 pytester.makepyfile(
967 **{
968 "app/foo.py": """
969 import pytest
970 def main():
971 pytest.main(['--pyargs', 'foo'])
972 """
973 }
974 )
975 target = pytester.path.joinpath("foo.zip")
976 zipapp.create_archive(
977 str(pytester.path.joinpath("app")), str(target), main="foo:main"
978 )
979 result = pytester.runpython(target)
980 assert result.ret == 0
981 result.stderr.fnmatch_lines(["*not found*foo*"])
982 result.stdout.no_fnmatch_line("*INTERNALERROR>*")
983
984
985def test_import_plugin_unicode_name(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 5

fnmatch_linesMethod · 0.80
no_fnmatch_lineMethod · 0.80
mkdirMethod · 0.45
makepyfileMethod · 0.45
runpythonMethod · 0.45

Tested by

no test coverage detected