MCPcopy Index your code
hub / github.com/python/cpython / RollbackImporter

Class RollbackImporter

Tools/unittestgui/unittestgui.py:188–199  ·  view source on GitHub ↗

This tricky little class is used to make sure that modules under test will be reloaded the next time they are imported.

Source from the content-addressed store, hash-verified

186
187
188class RollbackImporter:
189 """This tricky little class is used to make sure that modules under test
190 will be reloaded the next time they are imported.
191 """
192 def __init__(self):
193 self.previousModules = sys.modules.copy()
194
195 def rollbackImports(self):
196 for modname in sys.modules.copy().keys():
197 if not modname in self.previousModules:
198 # Force reload when modname next imported
199 del(sys.modules[modname])
200
201
202##############################################################################

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by 1

__init__Method · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…