예제 #1
0
def test_load_module():
    class DummyModule(modules.BaseModule):
        pass

    manager = Manager()

    manager.load_module(DummyModule)
    assert manager.get_wrapper(DummyModule) is not None

    manager.unload_module(DummyModule)
    assert manager.get_wrapper(DummyModule) is None
예제 #2
0
def test_load_twice():
    class DummyModule(modules.BaseModule):
        pass

    manager = Manager()

    manager.load_module(DummyModule)
    assert manager.get_wrapper(DummyModule) is not None
    assert len(manager.module_wrappers) == 1

    manager.load_module(DummyModule)
    assert manager.get_wrapper(DummyModule) is not None
    assert len(manager.module_wrappers) == 1
예제 #3
0
def test_get_wrapper():
    """Checks if get_wrapper properly handles inheritance. Ensures that
    a child is not returned when querying for a parent."""
    class DummyModule(modules.BaseModule):
        value = 'parent'

    class DummyModuleChild(DummyModule):
        value = 'child'

    def test(manager):
        parent = manager.get_wrapper(DummyModule)
        child = manager.get_wrapper(DummyModuleChild)
        assert parent.module.value == 'parent'
        assert child.module.value == 'child'

    manager = Manager()
    manager.load_module(DummyModule)
    manager.load_module(DummyModuleChild)
    test(manager)

    manager = Manager()
    manager.load_module(DummyModuleChild)
    manager.load_module(DummyModule)
    test(manager)