Changeset 222 for pyyaml/trunk/tests
- Timestamp:
- 08/03/06 12:07:29 (6 years ago)
- Location:
- pyyaml/trunk/tests
- Files:
-
- 9 added
- 4 modified
- 6 moved
-
data/duplicate-key.former-loader-error.code (added)
-
data/duplicate-key.former-loader-error.data (moved) (moved from pyyaml/trunk/tests/data/duplicate-key.loader-error)
-
data/duplicate-mapping-key.former-loader-error.code (added)
-
data/duplicate-mapping-key.former-loader-error.data (moved) (moved from pyyaml/trunk/tests/data/duplicate-mapping-key.loader-error)
-
data/duplicate-merge-key.former-loader-error.code (added)
-
data/duplicate-merge-key.former-loader-error.data (moved) (moved from pyyaml/trunk/tests/data/duplicate-merge-key.loader-error)
-
data/duplicate-value-key.former-loader-error.code (added)
-
data/duplicate-value-key.former-loader-error.data (moved) (moved from pyyaml/trunk/tests/data/duplicate-value-key.loader-error)
-
data/recurive-list.recursive (added)
-
data/recursive-anchor.former-loader-error (moved) (moved from pyyaml/trunk/tests/data/recursive-anchor.loader-error)
-
data/recursive-dict.recursive (added)
-
data/recursive-set.recursive (added)
-
data/recursive-state.recursive (added)
-
data/recursive-tuple.recursive (added)
-
data/recursive.former-dumper-error (moved) (moved from pyyaml/trunk/tests/data/recursive.dumper-error)
-
test_constructor.py (modified) (1 diff)
-
test_recursive.py (modified) (1 diff)
-
test_resolver.py (modified) (1 diff)
-
test_structure.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pyyaml/trunk/tests/test_constructor.py
r173 r222 240 240 def __eq__(self, other): 241 241 return type(self) is type(other) and dict(self) == dict(other) 242 243 def execute(code): 244 exec code 245 return value 242 246 243 247 class TestConstructorTypes(test_appliance.TestAppliance): -
pyyaml/trunk/tests/test_recursive.py
r142 r222 1 1 2 import unittest 2 import test_appliance 3 3 4 from yaml import * 4 5 5 RECURSIVE = """ 6 --- &A 7 - *A: *A 8 """ 6 class AnInstance: 9 7 10 class TestRecursive(unittest.TestCase): 8 def __init__(self, foo, bar): 9 self.foo = foo 10 self.bar = bar 11 11 12 def testRecursive(self):13 node = compose(RECURSIVE)14 self._check(node)15 document = serialize(node)16 node = compose(document)17 self._check(node)12 def __repr__(self): 13 try: 14 return "%s(foo=%r, bar=%r)" % (self.__class__.__name__, 15 self.foo, self.bar) 16 except RuntimeError: 17 return "%s(foo=..., bar=...)" % self.__class__.__name__ 18 18 19 def _check(self, node): 20 self.failUnless(node in node.value[0].value) 21 self.failUnless(node.value[0].value[node] is node) 19 class AnInstanceWithState(AnInstance): 22 20 21 def __getstate__(self): 22 return {'attributes': [self.foo, self.bar]} 23 24 def __setstate__(self, state): 25 self.foo, self.bar = state['attributes'] 26 27 class TestRecursive(test_appliance.TestAppliance): 28 29 def _testRecursive(self, test_name, recursive_filename): 30 exec file(recursive_filename, 'r').read() 31 value1 = value 32 output1 = None 33 value2 = None 34 output2 = None 35 try: 36 output1 = dump(value1) 37 #print "OUTPUT %s:" % test_name 38 #print output1 39 value2 = load(output1) 40 output2 = dump(value2) 41 self.failUnlessEqual(output1, output2) 42 except: 43 print "VALUE1:", value1 44 print "VALUE2:", value2 45 print "OUTPUT1:" 46 print output1 47 print "OUTPUT2:" 48 print output2 49 raise 50 51 TestRecursive.add_tests('testRecursive', '.recursive') 52 -
pyyaml/trunk/tests/test_resolver.py
r166 r222 73 73 elif isinstance(node, MappingNode): 74 74 value = [] 75 for key in node.value: 76 item = node.value[key] 75 for key, item in node.value: 77 76 value.append((self._convert(key), self._convert(item))) 78 77 value.sort() -
pyyaml/trunk/tests/test_structure.py
r146 r222 154 154 return self.construct_scalar(node) 155 155 156 MyLoader.add_constructor(u'tag:yaml.org,2002:map', MyLoader.construct_mapping) 156 157 MyLoader.add_constructor(None, MyLoader.construct_undefined) 157 158 … … 169 170 return self.construct_scalar(node) 170 171 172 MyCanonicalLoader.add_constructor(u'tag:yaml.org,2002:map', MyCanonicalLoader.construct_mapping) 171 173 MyCanonicalLoader.add_constructor(None, MyCanonicalLoader.construct_undefined) 172 174
