# HG changeset patch # User Stefano Rivera # Date 1378137652 -7200 # Node ID c5ff16c66100f520b4a666603703aa3690f8d1e8 # Parent 0280ee006d95bd75813536907b0635f673a89106 Support other interesting keys, too diff -r 0280ee006d95 -r c5ff16c66100 nagslang/tests/test_yamlish.py --- a/nagslang/tests/test_yamlish.py Mon Sep 02 17:58:35 2013 +0200 +++ b/nagslang/tests/test_yamlish.py Mon Sep 02 18:00:52 2013 +0200 @@ -98,6 +98,14 @@ 3: ['baz', 'qux'], }) + def test_dict_keys(self): + self.roundtrip({ + True: 'true', + False: [], + None: {}, + 0.7: -0.7, + }) + def test_quoted(self): # a literal true is True, but 'true' is a string self.roundtrip({'foo': 'true'}) diff -r 0280ee006d95 -r c5ff16c66100 nagslang/yamlish.py --- a/nagslang/yamlish.py Mon Sep 02 17:58:35 2013 +0200 +++ b/nagslang/yamlish.py Mon Sep 02 18:00:52 2013 +0200 @@ -64,7 +64,7 @@ def _dump_dict_block(self, data, indent): output = [] for k, v in sorted(data.iteritems()): - output.append('%s%s:' % (' ' * indent, k)) + output.append('%s%s:' % (' ' * indent, self._dump_inline(k))) if self._inlineable(v): output[-1] += ' ' + self._dump_inline(v) elif isinstance(v, dict):