示例#1
0
def test_on_config_changed(configdata_init, hook, module, option_filter,
                           option, called):
    module.info.config_changed_hooks = [(option_filter, hook)]

    info = loader.ExtensionInfo(name='testmodule')
    loader._load_component(info)
    loader._on_config_changed(option)

    assert hook.called == called
示例#2
0
def test_on_config_changed(configdata_init, hook, module,
                           option_filter, option, called):
    module.info.config_changed_hooks = [(option_filter, hook)]

    info = loader.ExtensionInfo(name='testmodule')
    loader._load_component(info)
    loader._on_config_changed(option)

    assert hook.called == called
示例#3
0
def test_skip_hooks(hook, module):
    hook.raising = True

    module.info.init_hook = hook
    module.info.config_changed_hooks = [(None, hook)]

    info = loader.ExtensionInfo(name='testmodule')
    loader._load_component(info, skip_hooks=True)
    loader._on_config_changed('test')

    assert not hook.called
示例#4
0
def test_skip_hooks(hook, module):
    hook.raising = True

    module.info.init_hook = hook
    module.info.config_changed_hooks = [(None, hook)]

    info = loader.ExtensionInfo(name='testmodule')
    loader._load_component(info, skip_hooks=True)
    loader._on_config_changed('test')

    assert not hook.called
示例#5
0
def test_load_component(monkeypatch):
    monkeypatch.setattr(objects, 'commands', {})

    info = loader.ExtensionInfo(name='qutebrowser.components.scrollcommands')
    mod = loader._load_component(info, skip_hooks=True)

    assert hasattr(mod, 'scroll_to_perc')
    assert 'scroll-to-perc' in objects.commands
示例#6
0
def test_load_component(monkeypatch):
    monkeypatch.setattr(objects, 'commands', {})

    info = loader.ExtensionInfo(name='qutebrowser.components.scrollcommands')
    mod = loader._load_component(info, skip_hooks=True)

    assert hasattr(mod, 'scroll_to_perc')
    assert 'scroll-to-perc' in objects.commands
示例#7
0
def test_init_hook(hook, module):
    module.info.init_hook = hook
    info = loader.ExtensionInfo(name='testmodule')
    loader._load_component(info)
    assert hook.called
示例#8
0
def test_init_hook(hook, module):
    module.info.init_hook = hook
    info = loader.ExtensionInfo(name='testmodule')
    loader._load_component(info)
    assert hook.called