summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_collections.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2010-09-12 05:28:42 (GMT)
committerRaymond Hettinger <python@rcn.com>2010-09-12 05:28:42 (GMT)
commit69976a7fbe7b3296d97a1e3169ec2b361feadfa9 (patch)
treed96c7eb7ffb90aa518e859b27bb17a358104a206 /Lib/test/test_collections.py
parent22450c2aee704f2485940ee792e301fc00dfde58 (diff)
downloadcpython-69976a7fbe7b3296d97a1e3169ec2b361feadfa9.zip
cpython-69976a7fbe7b3296d97a1e3169ec2b361feadfa9.tar.gz
cpython-69976a7fbe7b3296d97a1e3169ec2b361feadfa9.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 5e22afc..d435330 100644
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -908,6 +908,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)