diff options
author | Raymond Hettinger <python@rcn.com> | 2009-03-03 22:38:22 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2009-03-03 22:38:22 (GMT) |
commit | 5b26fb530bd26a63dac42383bbd8d3f4fd4e125a (patch) | |
tree | ce47b0a92cb72c86955b542a130ef5daefc0950c /Lib | |
parent | 14b89ffc7e7cf3fb7e65bf6350de2c53554515ea (diff) | |
download | cpython-5b26fb530bd26a63dac42383bbd8d3f4fd4e125a.zip cpython-5b26fb530bd26a63dac42383bbd8d3f4fd4e125a.tar.gz cpython-5b26fb530bd26a63dac42383bbd8d3f4fd4e125a.tar.bz2 |
Add another test.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_collections.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py index 1e23d5b..60d4e0b 100644 --- a/Lib/test/test_collections.py +++ b/Lib/test/test_collections.py @@ -719,6 +719,15 @@ class TestOrderedDict(unittest.TestCase): self.assertEquals(len(dup), len(od)) self.assertEquals(type(dup), type(od)) + def test_yaml_linkage(self): + # Verify that __reduce__ is setup in a way that supports PyYAML's dump() feature. + # In yaml, lists are native but tuples are not. + pairs = [('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)] + od = OrderedDict(pairs) + # yaml.dump(od) --> + # '!!python/object/apply:__main__.OrderedDict\n- - [a, 1]\n - [b, 2]\n' + self.assert_(all(type(pair)==list for pair in od.__reduce__()[1])) + def test_repr(self): od = OrderedDict([('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)]) self.assertEqual(repr(od), |