configtypes: Add a __repr__ to ValidValues.
This commit is contained in:
parent
8f48247b8f
commit
0b1704d829
@ -34,7 +34,7 @@ from PyQt5.QtWidgets import QTabWidget, QTabBar
|
|||||||
|
|
||||||
from qutebrowser.commands import cmdutils
|
from qutebrowser.commands import cmdutils
|
||||||
from qutebrowser.config import configexc
|
from qutebrowser.config import configexc
|
||||||
from qutebrowser.utils import standarddir
|
from qutebrowser.utils import standarddir, utils
|
||||||
|
|
||||||
|
|
||||||
SYSTEM_PROXY = object() # Return value for Proxy type
|
SYSTEM_PROXY = object() # Return value for Proxy type
|
||||||
@ -71,6 +71,10 @@ class ValidValues:
|
|||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return self.values.__iter__()
|
return self.values.__iter__()
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return utils.get_repr(self, values=self.values,
|
||||||
|
descriptions=self.descriptions)
|
||||||
|
|
||||||
|
|
||||||
class BaseType:
|
class BaseType:
|
||||||
|
|
||||||
|
@ -120,6 +120,15 @@ class TestValidValues:
|
|||||||
assert vv.descriptions['bar'] == "bar desc"
|
assert vv.descriptions['bar'] == "bar desc"
|
||||||
assert 'baz' not in vv.descriptions
|
assert 'baz' not in vv.descriptions
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('args, expected', [
|
||||||
|
(['a', 'b'], "<qutebrowser.config.configtypes.ValidValues "
|
||||||
|
"descriptions={} values=['a', 'b']>"),
|
||||||
|
([('val', 'desc')], "<qutebrowser.config.configtypes.ValidValues "
|
||||||
|
"descriptions={'val': 'desc'} values=['val']>"),
|
||||||
|
])
|
||||||
|
def test_repr(self, klass, args, expected):
|
||||||
|
assert repr(klass(*args)) == expected
|
||||||
|
|
||||||
|
|
||||||
class TestBaseType:
|
class TestBaseType:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user