Mercurial > nagslang
diff nagslang/tests/test_yamlish.py @ 129:423266f0b9e4
Support inline lists, dicts, etc. And alternative top level objects
author | Stefano Rivera <stefano@rivera.za.net> |
---|---|
date | Mon, 02 Sep 2013 16:57:59 +0200 |
parents | e6e7a471146a |
children | 67f18e72024d |
line wrap: on
line diff
--- a/nagslang/tests/test_yamlish.py Mon Sep 02 17:23:13 2013 +0200 +++ b/nagslang/tests/test_yamlish.py Mon Sep 02 16:57:59 2013 +0200 @@ -48,6 +48,9 @@ def test_simple_dict(self): self.roundtrip({'foo': 'bar'}) + def test_simple_list(self): + self.roundtrip(['foo', 'bar']) + def test_dict_of_dicts(self): self.roundtrip({'foo': {'bar': 'baz'}}) @@ -61,11 +64,20 @@ } }) + def test_list_of_lists(self): + self.roundtrip(['foo', ['bar', 'baz'], 'qux']) + def test_dict_list(self): self.roundtrip({ 'foo': ['bar', 'baz'], }) + def test_list_dict(self): + self.roundtrip([ + {'foo': 'bar'}, + {'baz': 'qux', 'quux': 'corge'}, + ]) + def test_nested_lists(self): self.roundtrip({ 'foo': [['bar', 'baz', 'qux'], 'quux'], @@ -97,6 +109,13 @@ return yaml.dump(data, default_flow_style=False) +class TestFromPyYAMLInlineLists(TestRoundTrip): + def dump_s(self, data): + if yaml is None: + raise SkipTest('yaml module unavailable') + return yaml.dump(data) + + class TestToPyYAML(TestRoundTrip): def load_s(self, text): if yaml is None: