summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_collections.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2010-09-12 05:15:22 (GMT)
committerRaymond Hettinger <python@rcn.com>2010-09-12 05:15:22 (GMT)
commitdc08a143e00d60aa0ce6ee946ad343b9ec2f80da (patch)
treeb039885d5aa71db994cb69b350a74d1c6fa858ac /Lib/test/test_collections.py
parentfa11db0a02f22f8141206102efc21b125989364d (diff)
downloadcpython-dc08a143e00d60aa0ce6ee946ad343b9ec2f80da.zip
cpython-dc08a143e00d60aa0ce6ee946ad343b9ec2f80da.tar.gz
cpython-dc08a143e00d60aa0ce6ee946ad343b9ec2f80da.tar.bz2
Issue #9826: Handle recursive repr in collections.OrderedDict.
Diffstat (limited to 'Lib/test/test_collections.py')
-rw-r--r--Lib/test/test_collections.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py
index 7beb061..514dc39 100644
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -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)