示例#1
0
def modules_system_emu():
    class ModulesSystemEmulator(modules.ModulesSystemImpl):
        '''A convenience class that simulates a modules system.'''
        def __init__(self):
            self._loaded_modules = set()

            # The following two variables record the sequence of loads and
            # unloads
            self.load_seq = []
            self.unload_seq = []

        def loaded_modules(self):
            return list(self._loaded_modules)

        def conflicted_modules(self, module):
            return []

        def load_module(self, module):
            self.load_seq.append(module.name)
            self._loaded_modules.add(module.name)

        def unload_module(self, module):
            self.unload_seq.append(module.name)
            try:
                self._loaded_modules.remove(module.name)
            except KeyError:
                pass

        def is_module_loaded(self, module):
            return module.name in self._loaded_modules

        def available_modules(self, substr):
            return []

        def name(self):
            return 'nomod_debug'

        def version(self):
            return '1.0'

        def unload_all(self):
            self._loaded_modules.clear()

        def searchpath(self):
            return []

        def searchpath_add(self, *dirs):
            pass

        def searchpath_remove(self, *dirs):
            pass

        def emit_load_instr(self, module):
            return ''

        def emit_unload_instr(self, module):
            return ''

    return modules.ModulesSystem(ModulesSystemEmulator())
示例#2
0
 def setUp(self):
     self.modules_activity = ModulesSystemEmulator()
     self.modules_system = modules.ModulesSystem(self.modules_activity)
     self.mapping_file = NamedTemporaryFile('wt', delete=False)