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

Method spy_factory

testing/test_pytester.py:229–243  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

227 assert result2.ret == ExitCode.TESTS_FAILED
228
229 def spy_factory(self):
230 class SysModulesSnapshotSpy:
231 instances: List["SysModulesSnapshotSpy"] = [] # noqa: F821
232
233 def __init__(self, preserve=None) -> None:
234 SysModulesSnapshotSpy.instances.append(self)
235 self._spy_restore_count = 0
236 self._spy_preserve = preserve
237 self.__snapshot = SysModulesSnapshot(preserve=preserve)
238
239 def restore(self):
240 self._spy_restore_count += 1
241 return self.__snapshot.restore()
242
243 return SysModulesSnapshotSpy
244
245 def test_inline_run_taking_and_restoring_a_sys_modules_snapshot(
246 self, pytester: Pytester, monkeypatch: MonkeyPatch

Calls

no outgoing calls

Tested by

no test coverage detected