Fix config tests for new Command type
This commit is contained in:
parent
2577b2c5e3
commit
2a40401398
@ -310,13 +310,14 @@ class FakeCommand:
|
||||
"""A simple command stub which has a description."""
|
||||
|
||||
def __init__(self, name='', desc='', hide=False, debug=False,
|
||||
deprecated=False, completion=None):
|
||||
deprecated=False, completion=None, maxsplit=None):
|
||||
self.desc = desc
|
||||
self.name = name
|
||||
self.hide = hide
|
||||
self.debug = debug
|
||||
self.deprecated = deprecated
|
||||
self.completion = completion
|
||||
self.maxsplit = maxsplit
|
||||
|
||||
|
||||
class FakeTimer(QObject):
|
||||
|
@ -19,18 +19,23 @@
|
||||
"""Tests for qutebrowser.config.configdata."""
|
||||
|
||||
import textwrap
|
||||
import types
|
||||
|
||||
import yaml
|
||||
import pytest
|
||||
|
||||
# To run cmdutils.register decorators
|
||||
from qutebrowser import app
|
||||
from qutebrowser.config import configdata, configtypes
|
||||
from qutebrowser.config import config, configdata, configtypes
|
||||
from qutebrowser.utils import usertypes
|
||||
|
||||
|
||||
def test_init():
|
||||
def test_init(monkeypatch):
|
||||
"""Test reading the default yaml file and validating the values."""
|
||||
# FIXME:conf use some kind of config_stub here
|
||||
ns = types.SimpleNamespace()
|
||||
ns.aliases = {}
|
||||
monkeypatch.setattr('qutebrowser.config.config.val', ns)
|
||||
configdata.init()
|
||||
assert isinstance(configdata.DATA, dict)
|
||||
assert 'ignore_case' in configdata.DATA
|
||||
|
@ -27,6 +27,7 @@ import collections
|
||||
import itertools
|
||||
import warnings
|
||||
import inspect
|
||||
import types
|
||||
import functools
|
||||
|
||||
import pytest
|
||||
@ -206,6 +207,14 @@ class TestAll:
|
||||
elif issubclass(member, configtypes.BaseType):
|
||||
yield member
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def patch(self, monkeypatch):
|
||||
"""Patch aliases so Command works."""
|
||||
# FIXME:conf use some kind of config_stub here
|
||||
ns = types.SimpleNamespace()
|
||||
ns.aliases = {}
|
||||
monkeypatch.setattr('qutebrowser.config.config.val', ns)
|
||||
|
||||
@pytest.fixture(params=list(gen_classes()))
|
||||
def klass(self, request):
|
||||
return request.param
|
||||
@ -1011,13 +1020,18 @@ class TestCommand:
|
||||
'cmd1': stubs.FakeCommand(desc="desc 1"),
|
||||
'cmd2': stubs.FakeCommand(desc="desc 2")})
|
||||
monkeypatch.setattr(configtypes, 'cmdutils', cmd_utils)
|
||||
# FIXME:conf use some kind of config_stub here
|
||||
ns = types.SimpleNamespace()
|
||||
ns.aliases = {'alias': 'cmd1'}
|
||||
monkeypatch.setattr('qutebrowser.config.config.val', ns)
|
||||
monkeypatch.setattr('qutebrowser.commands.runners.cmdutils', cmd_utils)
|
||||
|
||||
@pytest.fixture
|
||||
def klass(self):
|
||||
return configtypes.Command
|
||||
|
||||
@pytest.mark.parametrize('val', ['cmd1', 'cmd2', 'cmd1 foo bar',
|
||||
'cmd2 baz fish'])
|
||||
'cmd2 baz fish', 'alias foo'])
|
||||
def test_to_py_valid(self, klass, val):
|
||||
expected = None if not val else val
|
||||
assert klass().to_py(val) == expected
|
||||
@ -1523,7 +1537,7 @@ class TestDirectory:
|
||||
os_mock.path.expandvars.assert_called_once_with('$HOME/foobar')
|
||||
|
||||
def test_to_py_invalid_encoding(self, klass, os_mock,
|
||||
unicode_encode_err):
|
||||
unicode_encode_err):
|
||||
"""Test to_py with an invalid encoding, e.g. LC_ALL=C."""
|
||||
os_mock.path.isdir.side_effect = unicode_encode_err
|
||||
os_mock.path.isabs.side_effect = unicode_encode_err
|
||||
|
Loading…
Reference in New Issue
Block a user