MCPcopy
hub / github.com/pytest-dev/pytest / test_preserve_container

Method test_preserve_container

testing/test_pytester.py:357–366  ·  view source on GitHub ↗
(self, monkeypatch: MonkeyPatch)

Source from the content-addressed store, hash-verified

355 assert sys.modules == original
356
357 def test_preserve_container(self, monkeypatch: MonkeyPatch) -> None:
358 original = dict(sys.modules)
359 assert self.key not in original
360 replacement = dict(sys.modules)
361 replacement[self.key] = ModuleType("life of brian")
362 snapshot = SysModulesSnapshot()
363 monkeypatch.setattr(sys, "modules", replacement)
364 snapshot.restore()
365 assert sys.modules is replacement
366 assert sys.modules == original
367
368
369@pytest.mark.parametrize("path_type", ("path", "meta_path"))

Callers

nothing calls this directly

Calls 3

restoreMethod · 0.95
SysModulesSnapshotClass · 0.90
setattrMethod · 0.80

Tested by

no test coverage detected