mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Add another test.
This commit is contained in:
parent
14b89ffc7e
commit
5b26fb530b
1 changed files with 9 additions and 0 deletions
|
@ -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),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue