MCPcopy
hub / github.com/pytest-dev/pytest / test_zipimport_hook

Function test_zipimport_hook

testing/acceptance_test.py:1068–1088  ·  view source on GitHub ↗

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

(pytester: Pytester)

Source from the content-addressed store, hash-verified

1066
1067
1068def test_zipimport_hook(pytester: Pytester) -> None:
1069 """Test package loader is being used correctly (see #1837)."""
1070 zipapp = pytest.importorskip("zipapp")
1071 pytester.path.joinpath("app").mkdir()
1072 pytester.makepyfile(
1073 **{
1074 "app/foo.py": """
1075 import pytest
1076 def main():
1077 pytest.main(['--pyargs', 'foo'])
1078 """
1079 }
1080 )
1081 target = pytester.path.joinpath("foo.zip")
1082 zipapp.create_archive(
1083 str(pytester.path.joinpath("app")), str(target), main="foo:main"
1084 )
1085 result = pytester.runpython(target)
1086 assert result.ret == 0
1087 result.stderr.fnmatch_lines(["*not found*foo*"])
1088 result.stdout.no_fnmatch_line("*INTERNALERROR>*")
1089
1090
1091def 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