mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #9826: Handle recursive repr in collections.OrderedDict.
This commit is contained in:
parent
fa11db0a02
commit
dc08a143e0
3 changed files with 22 additions and 4 deletions
|
@ -951,6 +951,13 @@ class TestOrderedDict(unittest.TestCase):
|
|||
self.assertEqual(eval(repr(od)), od)
|
||||
self.assertEqual(repr(OrderedDict()), "OrderedDict()")
|
||||
|
||||
def test_repr_recursive(self):
|
||||
# See issue #9826
|
||||
od = OrderedDict.fromkeys('abc')
|
||||
od['x'] = od
|
||||
self.assertEqual(repr(od),
|
||||
"OrderedDict([('a', None), ('b', None), ('c', None), ('x', ...)])")
|
||||
|
||||
def test_setdefault(self):
|
||||
pairs = [('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)]
|
||||
shuffle(pairs)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue