From 7761dd5af4e1f0ee0c83cec80f4a61b78e931305 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 2 Oct 2015 11:37:41 +0200 Subject: [PATCH] configtypes: Disallow ValidValues without values. --- qutebrowser/config/configtypes.py | 2 ++ tests/unit/config/test_configtypes.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/qutebrowser/config/configtypes.py b/qutebrowser/config/configtypes.py index 4ad5037f4..5cfae02d8 100644 --- a/qutebrowser/config/configtypes.py +++ b/qutebrowser/config/configtypes.py @@ -79,6 +79,8 @@ class ValidValues: """ def __init__(self, *vals): + if not vals: + raise ValueError("ValidValues with no values makes no sense!") self.descriptions = {} self.values = [] for v in vals: diff --git a/tests/unit/config/test_configtypes.py b/tests/unit/config/test_configtypes.py index 2b3b44485..fadcfe042 100644 --- a/tests/unit/config/test_configtypes.py +++ b/tests/unit/config/test_configtypes.py @@ -159,6 +159,10 @@ class TestValidValues: def test_repr(self, klass, args, expected): assert repr(klass(*args)) == expected + def test_empty(self, klass): + with pytest.raises(ValueError): + klass() + class TestBaseType: