source: nagslang/tests/test_level_serializer.py@ 89:102043902451

Last change on this file since 89:102043902451 was 89:102043902451, checked in by Stefano Rivera <stefano@…>, 8 years ago

Simple (subset of) YAML parser

File size: 1.1 KB
Line 
1from unittest import TestCase
2from StringIO import StringIO
3
4from nagslang.level_serializer import load, dump
5
6
7class TestSimple(TestCase):
8 def roundtrip(self, data):
9 f = StringIO()
10 dump(data, f)
11 f.seek(0)
12 #print '\n== Begin ==\n%s== End ==' % f.buf
13 self.assertEqual(load(f), data)
14
15 def test_simple_dict(self):
16 self.roundtrip({'foo': 'bar'})
17
18 def test_dict_of_dicts(self):
19 self.roundtrip({'foo': {'bar': 'baz'}})
20
21 def test_dict_tree(self):
22 self.roundtrip({
23 'foo': {
24 'bar': {
25 'baz': 'qux'
26 },
27 'quux': 'corge',
28 }
29 })
30
31 def test_dict_list(self):
32 self.roundtrip({
33 'foo': ['bar', 'baz'],
34 })
35
36 def test_nested_lists(self):
37 self.roundtrip({
38 'foo': [['bar', 'baz', 'qux'], 'quux'],
39 })
40
41 def test_list_of_dicts(self):
42 self.roundtrip({
43 'foo': [
44 {'bar': 'baz'},
45 {'qux': 'quux'},
46 ],
47 })
Note: See TracBrowser for help on using the repository browser.