diff options
author | Florian Bruhin <git@the-compiler.org> | 2016-01-12 18:51:12 +0100 |
---|---|---|
committer | Florian Bruhin <git@the-compiler.org> | 2016-01-18 21:35:29 +0100 |
commit | a362efaa5664051e9d478562259821df83a773d3 (patch) | |
tree | 4ee246a3deceeb3a6e24e9f81722815c9b6bbbc8 | |
parent | 8bd4d3d24a54891858e1619250c4d08222e193b2 (diff) | |
download | qutebrowser-a362efaa5664051e9d478562259821df83a773d3.tar.gz qutebrowser-a362efaa5664051e9d478562259821df83a773d3.zip |
Fix completion for String config type.
Since 2a705e2eb62d5f2e8052f036c8b520203b51f537 non-specialized config types are
String. However, String had an overloaded complete() which defaulted to
returning None.
Now we use the normal complete() which relies on valid_values if completions
isn't given instead.
Fixes #1223.
-rw-r--r-- | qutebrowser/config/configtypes.py | 5 | ||||
-rw-r--r-- | tests/unit/config/test_configtypes.py | 9 |
2 files changed, 13 insertions, 1 deletions
diff --git a/qutebrowser/config/configtypes.py b/qutebrowser/config/configtypes.py index bd9af1f33..dbcb13fa5 100644 --- a/qutebrowser/config/configtypes.py +++ b/qutebrowser/config/configtypes.py @@ -270,7 +270,10 @@ class String(BaseType): "long!".format(self.maxlen)) def complete(self): - return self._completions + if self._completions is not None: + return self._completions + else: + return super().complete() class List(BaseType): diff --git a/tests/unit/config/test_configtypes.py b/tests/unit/config/test_configtypes.py index d2dd2886b..b746ba035 100644 --- a/tests/unit/config/test_configtypes.py +++ b/tests/unit/config/test_configtypes.py @@ -335,6 +335,15 @@ class TestString: def test_complete(self, klass, value): assert klass(completions=value).complete() == value + @pytest.mark.parametrize('valid_values, expected', [ + (configtypes.ValidValues('one', 'two'), + [('one', ''), ('two', '')]), + (configtypes.ValidValues(('1', 'one'), ('2', 'two')), + [('1', 'one'), ('2', 'two')]), + ]) + def test_complete_valid_values(self, klass, valid_values, expected): + assert klass(valid_values=valid_values).complete() == expected + class TestList: |