Sort keys in configtypes.Dict.to_str
Otherwise, we get inconsistent output between runs on Python 3.5
This commit is contained in:
parent
f63eb8ea15
commit
c689760872
@ -1295,7 +1295,7 @@ class Dict(BaseType):
|
|||||||
if not value:
|
if not value:
|
||||||
# An empty Dict is treated just like None -> empty string
|
# An empty Dict is treated just like None -> empty string
|
||||||
return ''
|
return ''
|
||||||
return json.dumps(value)
|
return json.dumps(value, sort_keys=True)
|
||||||
|
|
||||||
def to_doc(self, value, indent=0):
|
def to_doc(self, value, indent=0):
|
||||||
if not value:
|
if not value:
|
||||||
|
@ -844,8 +844,8 @@ def test_setting_option_completion(qtmodeltester, config_stub,
|
|||||||
"Options": [
|
"Options": [
|
||||||
('aliases', 'Aliases for commands.', '{"q": "quit"}'),
|
('aliases', 'Aliases for commands.', '{"q": "quit"}'),
|
||||||
('bindings.commands', 'Default keybindings', (
|
('bindings.commands', 'Default keybindings', (
|
||||||
'{"normal": {"<Ctrl+q>": "quit", "ZQ": "quit", '
|
'{"normal": {"<Ctrl+q>": "quit", "I": "invalid", '
|
||||||
'"I": "invalid", "d": "scroll down"}}')),
|
'"ZQ": "quit", "d": "scroll down"}}')),
|
||||||
('completion.open_categories', 'Which categories to show (in '
|
('completion.open_categories', 'Which categories to show (in '
|
||||||
'which order) in the :open completion.',
|
'which order) in the :open completion.',
|
||||||
'["searchengines", "quickmarks", "bookmarks", "history"]'),
|
'["searchengines", "quickmarks", "bookmarks", "history"]'),
|
||||||
|
@ -1703,6 +1703,11 @@ class TestDict:
|
|||||||
value = typ.from_obj({'1': '2'})
|
value = typ.from_obj({'1': '2'})
|
||||||
assert value == {'1': 2}
|
assert value == {'1': 2}
|
||||||
|
|
||||||
|
def test_to_str(self, klass):
|
||||||
|
typ = klass(keytype=configtypes.String(), valtype=configtypes.String())
|
||||||
|
d = {'a': 'b', 'c': 'd'}
|
||||||
|
assert typ.to_str(d) == '{"a": "b", "c": "d"}'
|
||||||
|
|
||||||
|
|
||||||
def unrequired_class(**kwargs):
|
def unrequired_class(**kwargs):
|
||||||
return configtypes.File(required=False, **kwargs)
|
return configtypes.File(required=False, **kwargs)
|
||||||
|
Loading…
Reference in New Issue
Block a user