Пример #1
0
def test_get_module_class():
    # load module from string
    modules = get_module_class('enhancements.examples.HexDump')
    assert issubclass(modules[0], Module)

    # load module from class
    modules2 = get_module_class(HexDump)
    assert issubclass(modules2[0], Module)

    # try to load empty module list
    modules = get_module_class(None)
    assert isinstance(modules, list)
    assert not modules

    # try to load invalid package and class
    assert not get_module_class(1234)
Пример #2
0
def test_get_module_class():
    # load module from string
    modules = get_module_class('enhancements.examples.HexDump')
    assert issubclass(modules[0], BaseModule)

    # load module from class
    modules2 = get_module_class(HexDump)
    assert issubclass(modules2[0], BaseModule)

    # try to load empty module list
    with pytest.raises(TypeError):
        modules = get_module_class(None)

    # try to load invalid package and class
    with pytest.raises(TypeError):
        assert not get_module_class(1234)
Пример #3
0
 def _getmodule_option(self, section: Text, option: Text) -> Type[Module]:
     """ get a module class from config file
     """
     module = self.get(section, option)
     values = get_module_class(module,
                               modules_from_file=self.modules_from_file)
     if not values:
         raise ValueError(
             'Not a valid module class! section: {}, option: {}, value: {}'.
             format(section, option, module))
     return values[0]