MCPcopy Index your code
hub / github.com/pytest-dev/pytest / test_restore

Method test_restore

testing/test_pytester.py:377–398  ·  view source on GitHub ↗
(self, monkeypatch: MonkeyPatch, path_type)

Source from the content-addressed store, hash-verified

375 return "my-dirty-little-secret-" + str(n)
376
377 def test_restore(self, monkeypatch: MonkeyPatch, path_type) -> None:
378 other_path_type = self.other_path[path_type]
379 for i in range(10):
380 assert self.path(i) not in getattr(sys, path_type)
381 sys_path = [self.path(i) for i in range(6)]
382 monkeypatch.setattr(sys, path_type, sys_path)
383 original = list(sys_path)
384 original_other = list(getattr(sys, other_path_type))
385 snapshot = SysPathsSnapshot()
386 transformation = {"source": (0, 1, 2, 3, 4, 5), "target": (6, 2, 9, 7, 5, 8)}
387 assert sys_path == [self.path(x) for x in transformation["source"]]
388 sys_path[1] = self.path(6)
389 sys_path[3] = self.path(7)
390 sys_path.append(self.path(8))
391 del sys_path[4]
392 sys_path[3:3] = [self.path(9)]
393 del sys_path[0]
394 assert sys_path == [self.path(x) for x in transformation["target"]]
395 snapshot.restore()
396 assert getattr(sys, path_type) is sys_path
397 assert getattr(sys, path_type) == original
398 assert getattr(sys, other_path_type) == original_other
399
400 def test_preserve_container(self, monkeypatch: MonkeyPatch, path_type) -> None:
401 other_path_type = self.other_path[path_type]

Callers

nothing calls this directly

Calls 5

pathMethod · 0.95
restoreMethod · 0.95
SysPathsSnapshotClass · 0.90
setattrMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected