Changeset 344:1d73867becbe for nagslang


Ignore:
Timestamp:
Sep 6, 2013, 11:38:07 AM (7 years ago)
Author:
Stefano Rivera <stefano@…>
Branch:
default
Message:

Allow tuples in dicts

Location:
nagslang
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • nagslang/tests/test_yamlish.py

    r138 r344  
    127127                         tuple(result['polygons'][1][1]))
    128128
     129    def test_dict_tuples(self):
     130        if self.from_pyyaml:
     131            raise SkipTest("Can't parse PyYAML tuples")
     132        orig = {'tuple': (0, 1)}
     133        text = self.dump_s(orig)
     134        result = self.load_s(text)
     135        self.assertEqual(orig['tuple'],
     136                         tuple(result['tuple']))
     137
    129138    def test_quoted(self):
    130139        # a literal true is True, but 'true' is a string
  • nagslang/yamlish.py

    r141 r344  
    7272            elif isinstance(v, dict):
    7373                output += self._dump_block(v, indent + 2)
    74             elif isinstance(v, list):
     74            elif isinstance(v, (list, tuple)):
    7575                output += self._dump_block(v, indent)
    7676            else:
    77                 raise NotImplementedError()
     77                raise NotImplementedError("Cannot dump %r", data)
    7878        return output
    7979
Note: See TracChangeset for help on using the changeset viewer.