# HG changeset patch # User Stefano Rivera # Date 1378467487 -7200 # Node ID 1d73867becbe4f4459e0dfe20db31e2aa62e3348 # Parent e5f525c87eb982ce523b147b21e6ec89ff03bd79 Allow tuples in dicts diff -r e5f525c87eb9 -r 1d73867becbe nagslang/tests/test_yamlish.py --- a/nagslang/tests/test_yamlish.py Fri Sep 06 12:58:46 2013 +0200 +++ b/nagslang/tests/test_yamlish.py Fri Sep 06 13:38:07 2013 +0200 @@ -126,6 +126,15 @@ self.assertEqual(orig['polygons'][1][1], tuple(result['polygons'][1][1])) + def test_dict_tuples(self): + if self.from_pyyaml: + raise SkipTest("Can't parse PyYAML tuples") + orig = {'tuple': (0, 1)} + text = self.dump_s(orig) + result = self.load_s(text) + self.assertEqual(orig['tuple'], + tuple(result['tuple'])) + def test_quoted(self): # a literal true is True, but 'true' is a string self.roundtrip({'foo': 'true'}) diff -r e5f525c87eb9 -r 1d73867becbe nagslang/yamlish.py --- a/nagslang/yamlish.py Fri Sep 06 12:58:46 2013 +0200 +++ b/nagslang/yamlish.py Fri Sep 06 13:38:07 2013 +0200 @@ -71,10 +71,10 @@ output[-1] += ' ' + self._dump_inline(v) elif isinstance(v, dict): output += self._dump_block(v, indent + 2) - elif isinstance(v, list): + elif isinstance(v, (list, tuple)): output += self._dump_block(v, indent) else: - raise NotImplementedError() + raise NotImplementedError("Cannot dump %r", data) return output def _inlineable(self, data):