[Python-checkins] r70141 - python/branches/py3k/Lib/test/test_collections.py
raymond.hettinger
python-checkins at python.org
Tue Mar 3 23:38:24 CET 2009
Author: raymond.hettinger
Date: Tue Mar 3 23:38:22 2009
New Revision: 70141
Log:
Add another test.
Modified:
python/branches/py3k/Lib/test/test_collections.py
Modified: python/branches/py3k/Lib/test/test_collections.py
==============================================================================
--- python/branches/py3k/Lib/test/test_collections.py (original)
+++ python/branches/py3k/Lib/test/test_collections.py Tue Mar 3 23:38:22 2009
@@ -719,6 +719,15 @@
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),
More information about the Python-checkins
mailing list