(
self, tmp_path: Path, monkeypatch: MonkeyPatch, ns_param: bool
)
| 204 | ) |
| 205 | |
| 206 | def test_renamed_dir_creates_mismatch( |
| 207 | self, tmp_path: Path, monkeypatch: MonkeyPatch, ns_param: bool |
| 208 | ) -> None: |
| 209 | tmp_path.joinpath("a").mkdir() |
| 210 | p = tmp_path.joinpath("a", "test_x123.py") |
| 211 | p.touch() |
| 212 | import_path(p, root=tmp_path, consider_namespace_packages=ns_param) |
| 213 | tmp_path.joinpath("a").rename(tmp_path.joinpath("b")) |
| 214 | with pytest.raises(ImportPathMismatchError): |
| 215 | import_path( |
| 216 | tmp_path.joinpath("b", "test_x123.py"), |
| 217 | root=tmp_path, |
| 218 | consider_namespace_packages=ns_param, |
| 219 | ) |
| 220 | |
| 221 | # Errors can be ignored. |
| 222 | monkeypatch.setenv("PY_IGNORE_IMPORTMISMATCH", "1") |
| 223 | import_path( |
| 224 | tmp_path.joinpath("b", "test_x123.py"), |
| 225 | root=tmp_path, |
| 226 | consider_namespace_packages=ns_param, |
| 227 | ) |
| 228 | |
| 229 | # PY_IGNORE_IMPORTMISMATCH=0 does not ignore error. |
| 230 | monkeypatch.setenv("PY_IGNORE_IMPORTMISMATCH", "0") |
| 231 | with pytest.raises(ImportPathMismatchError): |
| 232 | import_path( |
| 233 | tmp_path.joinpath("b", "test_x123.py"), |
| 234 | root=tmp_path, |
| 235 | consider_namespace_packages=ns_param, |
| 236 | ) |
| 237 | |
| 238 | def test_messy_name(self, tmp_path: Path, ns_param: bool) -> None: |
| 239 | # https://bitbucket.org/hpk42/py-trunk/issue/129 |
nothing calls this directly
no test coverage detected