summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2011-01-01 22:38:00 (GMT)
committerRaymond Hettinger <python@rcn.com>2011-01-01 22:38:00 (GMT)
commit32062e9be78ee49b563d1b7eb290a00e6fe16c0f (patch)
treebff5fdfbf490eb0447c9e1ad19e3816f82e07f91 /Lib/test
parent60db46758fa4dd5786a17226794c8b1eaa3c6094 (diff)
downloadcpython-32062e9be78ee49b563d1b7eb290a00e6fe16c0f.zip
cpython-32062e9be78ee49b563d1b7eb290a00e6fe16c0f.tar.gz
cpython-32062e9be78ee49b563d1b7eb290a00e6fe16c0f.tar.bz2
Make it easier to extend OrderedDict without breaking it.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_collections.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py
index 32ce35b..8c95979 100644
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -1012,6 +1012,14 @@ class TestOrderedDict(unittest.TestCase):
od = OrderedDict(**d)
self.assertGreater(sys.getsizeof(od), sys.getsizeof(d))
+ def test_override_update(self):
+ # Verify that subclasses can override update() without breaking __init__()
+ class MyOD(OrderedDict):
+ def update(self, *args, **kwds):
+ raise Exception()
+ items = [('a', 1), ('c', 3), ('b', 2)]
+ self.assertEqual(list(MyOD(items).items()), items)
+
class GeneralMappingTests(mapping_tests.BasicTestMappingProtocol):
type2test = OrderedDict