Test package loader is being used correctly (see #1837).
(pytester: Pytester)
| 1066 | |
| 1067 | |
| 1068 | def 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 | |
| 1091 | def test_import_plugin_unicode_name(pytester: Pytester) -> None: |
nothing calls this directly
no test coverage detected