MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_renamed_dir_creates_mismatch

Method test_renamed_dir_creates_mismatch

testing/test_pathlib.py:146–164  ·  view source on GitHub ↗
(
        self, tmp_path: Path, monkeypatch: MonkeyPatch
    )

Source from the content-addressed store, hash-verified

144 assert obj.__name__ == "execfile"
145
146 def test_renamed_dir_creates_mismatch(
147 self, tmp_path: Path, monkeypatch: MonkeyPatch
148 ) -> None:
149 tmp_path.joinpath("a").mkdir()
150 p = tmp_path.joinpath("a", "test_x123.py")
151 p.touch()
152 import_path(p, root=tmp_path)
153 tmp_path.joinpath("a").rename(tmp_path.joinpath("b"))
154 with pytest.raises(ImportPathMismatchError):
155 import_path(tmp_path.joinpath("b", "test_x123.py"), root=tmp_path)
156
157 # Errors can be ignored.
158 monkeypatch.setenv("PY_IGNORE_IMPORTMISMATCH", "1")
159 import_path(tmp_path.joinpath("b", "test_x123.py"), root=tmp_path)
160
161 # PY_IGNORE_IMPORTMISMATCH=0 does not ignore error.
162 monkeypatch.setenv("PY_IGNORE_IMPORTMISMATCH", "0")
163 with pytest.raises(ImportPathMismatchError):
164 import_path(tmp_path.joinpath("b", "test_x123.py"), root=tmp_path)
165
166 def test_messy_name(self, tmp_path: Path) -> None:
167 # https://bitbucket.org/hpk42/py-trunk/issue/129

Callers

nothing calls this directly

Calls 3

import_pathFunction · 0.90
setenvMethod · 0.80
mkdirMethod · 0.45

Tested by

no test coverage detected