Beispiel #1
0
    def __init__(self, config):
        """Constructor"""
        self.config = config

        if self.config.get("engine.type") != 'local':
            raise InitializationError
        self.engine_factory = dynamic_create(self.config.string("engine._provider"))
        self.engine = self.engine_factory.create_engine(self.config.section("engine"))
Beispiel #2
0
 def __init__(self, config):
     """Constructor"""
     factory_classname = config.string('database._provider')
     factory = dynamic_create(factory_classname)
     self._persistor = factory.create_persistor(config.section('database'))
Beispiel #3
0
def test_dynamic_create():
    """Test to make sure we can dynamically load a class and create an instance of said class."""
    obj1 = dynamic_create('test_loader.TestClassForLoad')
    assert isinstance(obj1, TestClassForLoad)
    with pytest.raises(ImportError):
        dynamic_create('bogus_package.bogus_class')