Even without any meta_path should still import module.
(
self, simple_module: Path, monkeypatch: MonkeyPatch, tmp_path: Path
)
| 295 | assert module1 is not module2 |
| 296 | |
| 297 | def test_no_meta_path_found( |
| 298 | self, simple_module: Path, monkeypatch: MonkeyPatch, tmp_path: Path |
| 299 | ) -> None: |
| 300 | """Even without any meta_path should still import module.""" |
| 301 | monkeypatch.setattr(sys, "meta_path", []) |
| 302 | module = import_path(simple_module, mode="importlib", root=tmp_path) |
| 303 | assert module.foo(2) == 42 # type: ignore[attr-defined] |
| 304 | |
| 305 | # mode='importlib' fails if no spec is found to load the module |
| 306 | import importlib.util |
| 307 | |
| 308 | monkeypatch.setattr( |
| 309 | importlib.util, "spec_from_file_location", lambda *args: None |
| 310 | ) |
| 311 | with pytest.raises(ImportError): |
| 312 | import_path(simple_module, mode="importlib", root=tmp_path) |
| 313 | |
| 314 | |
| 315 | def test_resolve_package_path(tmp_path: Path) -> None: |
nothing calls this directly
no test coverage detected