code: def tzpath_context(self, tzpath, block_tzdata=True, lock=TZPATH_LOCK):
      def pop_tzdata_modules():
          tzdata_modules = {}
          for modname in list(sys.modules):
              if (
                  modname.split(".", 1)[0] != "tzdata"
              ):  # pragma: nocover
                  continue
  
              tzdata_modules[modname] = sys.modules.pop(modname)
  
          return tzdata_modules
  
      with lock:
          if block_tzdata:
              # In order to fully exclude tzdata from the path, we need to
              # clear the sys.modules cache of all its contents — setting the
              # root package to None is not enough to block direct access of
              # already-imported submodules (though it will prevent new
              # imports of submodules).
              tzdata_modules = pop_tzdata_modules()
              sys.modules["tzdata"] = None
  
          old_path = self.module.TZPATH
          try:
              self.module.reset_tzpath(tzpath)
              yield
          finally:
              if block_tzdata:
                  sys.modules.pop("tzdata")
                  for modname, module in tzdata_modules.items():
                      sys.modules[modname] = module
  
              self.module.reset_tzpath(old_path)
  
file_path: cpython/Lib/test/test_zoneinfo/_support.py
imports: import contextlib
  import functools
  import sys
  import threading
  import unittest
  from test.support.import_helper import import_fresh_module
label_desc: Use image node_id 2 for calling the ZoneInfoTestBase obj's underlying member method code with example usage: obj.tzpath_context(tzpath, block_tzdata, lock) and returns: tzdata_modules