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

Method test_preserve_container

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

Source from the content-addressed store, hash-verified

364 assert sys.modules == original
365
366 def test_preserve_container(self, monkeypatch: MonkeyPatch) -> None:
367 original = dict(sys.modules)
368 assert self.key not in original
369 replacement = dict(sys.modules)
370 replacement[self.key] = ModuleType("life of brian")
371 snapshot = SysModulesSnapshot()
372 monkeypatch.setattr(sys, "modules", replacement)
373 snapshot.restore()
374 assert sys.modules is replacement
375 assert sys.modules == original
376
377
378@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