def METHOD_NAME(self, apt_mock):
    modules = {'apt': apt_mock}
    self.module_patcher = patch.dict('sys.modules', modules)
    self.module_patcher.start()
    self.addCleanup(self.module_patcher.stop)