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:
|
||||
# An empty Dict is treated just like None -> empty string
|
||||
return ''
|
||||
return json.dumps(value)
|
||||
return json.dumps(value, sort_keys=True)
|
||||
|
||||
def to_doc(self, value, indent=0):
|
||||
if not value:
|
||||
|
@ -844,8 +844,8 @@ def test_setting_option_completion(qtmodeltester, config_stub,
|
||||
"Options": [
|
||||
('aliases', 'Aliases for commands.', '{"q": "quit"}'),
|
||||
('bindings.commands', 'Default keybindings', (
|
||||
'{"normal": {"<Ctrl+q>": "quit", "ZQ": "quit", '
|
||||
'"I": "invalid", "d": "scroll down"}}')),
|
||||
'{"normal": {"<Ctrl+q>": "quit", "I": "invalid", '
|
||||
'"ZQ": "quit", "d": "scroll down"}}')),
|
||||
('completion.open_categories', 'Which categories to show (in '
|
||||
'which order) in the :open completion.',
|
||||
'["searchengines", "quickmarks", "bookmarks", "history"]'),
|
||||
|
@ -1703,6 +1703,11 @@ class TestDict:
|
||||
value = typ.from_obj({'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):
|
||||
return configtypes.File(required=False, **kwargs)
|
||||
|
Loading…
Reference in New Issue
Block a user