(
self, monkeypatch: MonkeyPatch, tmp_path: Path
)
| 214 | assert module1 is mod1 |
| 215 | |
| 216 | def test_check_filepath_consistency( |
| 217 | self, monkeypatch: MonkeyPatch, tmp_path: Path |
| 218 | ) -> None: |
| 219 | name = "pointsback123" |
| 220 | p = tmp_path.joinpath(name + ".py") |
| 221 | p.touch() |
| 222 | for ending in (".pyc", ".pyo"): |
| 223 | mod = ModuleType(name) |
| 224 | pseudopath = tmp_path.joinpath(name + ending) |
| 225 | pseudopath.touch() |
| 226 | mod.__file__ = str(pseudopath) |
| 227 | monkeypatch.setitem(sys.modules, name, mod) |
| 228 | newmod = import_path(p, root=tmp_path) |
| 229 | assert mod == newmod |
| 230 | monkeypatch.undo() |
| 231 | mod = ModuleType(name) |
| 232 | pseudopath = tmp_path.joinpath(name + "123.py") |
| 233 | pseudopath.touch() |
| 234 | mod.__file__ = str(pseudopath) |
| 235 | monkeypatch.setitem(sys.modules, name, mod) |
| 236 | with pytest.raises(ImportPathMismatchError) as excinfo: |
| 237 | import_path(p, root=tmp_path) |
| 238 | modname, modfile, orig = excinfo.value.args |
| 239 | assert modname == name |
| 240 | assert modfile == str(pseudopath) |
| 241 | assert orig == p |
| 242 | assert issubclass(ImportPathMismatchError, ImportError) |
| 243 | |
| 244 | def test_issue131_on__init__(self, tmp_path: Path) -> None: |
| 245 | # __init__.py files may be namespace packages, and thus the |
nothing calls this directly
no test coverage detected