code: def test_inline_run_taking_and_restoring_a_sys_modules_snapshot(
      self, pytester: Pytester, monkeypatch: MonkeyPatch
  ) -> None:
      spy_factory = self.spy_factory()
      monkeypatch.setattr(
          pytester_mod, "SysModulesSnapshot", spy_factory
      )
      pytester.syspathinsert()
      original = dict(sys.modules)
      pytester.makepyfile(import1="# you son of a silly person")
      pytester.makepyfile(import2="# my hovercraft is full of eels")
      test_mod = pytester.makepyfile(
          """
              import import1
              def test_foo(): import import2"""
      )
      pytester.inline_run(str(test_mod))
      assert len(spy_factory.instances) == 1
      spy = spy_factory.instances[0]
      assert spy._spy_restore_count == 1
      assert sys.modules == original
      assert all(sys.modules[x] is original[x] for x in sys.modules)
  
imports: import os
  import subprocess
  import sys
  import time
  from types import ModuleType
  from typing import List
  import _pytest.pytester
  import pytest
  from _pytest.config import ExitCode
  from _pytest.config import PytestPluginManager
  from _pytest.monkeypatch import MonkeyPatch
  from _pytest.pytester import HookRecorder
  from _pytest.pytester import LineMatcher
  from _pytest.pytester import Pytester
  from _pytest.pytester import SysModulesSnapshot
  from _pytest.pytester import SysPathsSnapshot
label_desc: Use image node_id 3 for calling the TestInlineRunModulesCleanup obj's underlying member method code with example usage: obj.test_inline_run_taking_and_restoring_a_sys_modules_snapshot(pytester, monkeypatch) without return types