Add a test for cmd instance with wrong backend

This commit is contained in:
Florian Bruhin 2016-07-08 20:31:09 +02:00
parent fd8e66136f
commit 34e39bed4e
2 changed files with 19 additions and 1 deletions

View File

@ -518,7 +518,6 @@ class Command:
e.status, e))
return
self._count = count
# FIXME add tests for the _check_prerequisites move!
self._check_prerequisites(win_id)
posargs, kwargs = self._get_call_args(win_id)
log.commands.debug('Calling {}'.format(

View File

@ -393,3 +393,22 @@ class TestRun:
def test_no_args(self):
cmd = _get_cmd()
cmd.run(win_id=0)
def test_instance_unavailable_with_backend(self, fake_args):
"""Test what happens when a backend doesn't have an objreg object.
For example, QtWebEngine doesn't have 'hintmanager' registered. We make
sure the backend checking happens before resolving the instance, so we
display an error instead of crashing.
"""
@cmdutils.register(instance='doesnotexist',
backend=tabmod.Backend.QtWebEngine)
def fun(self):
"""Blah."""
pass
fake_args.backend = 'webkit'
cmd = cmdutils.cmd_dict['fun']
with pytest.raises(cmdexc.PrerequisitesError) as excinfo:
cmd.run(win_id=0)
assert str(excinfo.value).endswith(' backend.')