def __exit__(self, *args): if self.hooks_were_installed: install_hooks() # restore_sys_modules(self.scrubbed)