(tmp_path_factory)
| 177 | |
| 178 | @pytest.fixture(scope="session", autouse=True) |
| 179 | def isolate(tmp_path_factory): |
| 180 | path = tmp_path_factory.mktemp("mock") |
| 181 | home_dir = path / "home" |
| 182 | home_dir.mkdir() |
| 183 | |
| 184 | monkeypatch = pytest.MonkeyPatch() |
| 185 | if sys.platform == "win32": |
| 186 | home_drive, home_path = os.path.splitdrive(home_dir) |
| 187 | monkeypatch.setenv("USERPROFILE", str(home_dir)) |
| 188 | monkeypatch.setenv("HOMEDRIVE", home_drive) |
| 189 | monkeypatch.setenv("HOMEPATH", home_path) |
| 190 | |
| 191 | for env_var, sub_path in (("APPDATA", "Roaming"), ("LOCALAPPDATA", "Local")): |
| 192 | path = home_dir / "AppData" / sub_path |
| 193 | path.mkdir(parents=True) |
| 194 | monkeypatch.setenv(env_var, os.fspath(path)) |
| 195 | else: |
| 196 | monkeypatch.setenv("HOME", str(home_dir)) |
| 197 | monkeypatch.setenv("XDG_CONFIG_HOME", str(home_dir / ".config")) |
| 198 | |
| 199 | monkeypatch.setenv("GIT_CONFIG_NOSYSTEM", "1") |
| 200 | contents = b""" |
| 201 | [user] |
| 202 | name=DVC Tester |
| 203 | email=dvctester@example.com |
| 204 | [init] |
| 205 | defaultBranch=master |
| 206 | """ |
| 207 | (home_dir / ".gitconfig").write_bytes(contents) |
| 208 | |
| 209 | import pygit2 |
| 210 | |
| 211 | pygit2.settings.search_path[pygit2.GIT_CONFIG_LEVEL_GLOBAL] = str(home_dir) |
| 212 | |
| 213 | monkeypatch.setenv(env.DVC_SYSTEM_CONFIG_DIR, os.fspath(path / "system")) |
| 214 | monkeypatch.setenv(env.DVC_GLOBAL_CONFIG_DIR, os.fspath(path / "global")) |
| 215 | monkeypatch.setenv(env.DVC_SITE_CACHE_DIR, os.fspath(path / "site_cache_dir")) |
| 216 | |
| 217 | yield |
| 218 | |
| 219 | monkeypatch.undo() |
| 220 | |
| 221 | |
| 222 | @pytest.fixture |
nothing calls this directly
no test coverage detected