diff options
| author | Raymond Hettinger <python@rcn.com> | 2009-03-03 22:50:04 (GMT) |
|---|---|---|
| committer | Raymond Hettinger <python@rcn.com> | 2009-03-03 22:50:04 (GMT) |
| commit | b212157465b82e97f5d9e5fdefafe933cb2c0487 (patch) | |
| tree | 7d8b82536c8cff2cf74d1e495f28cf9fb9286ba5 /Lib/test/test_collections.py | |
| parent | 89194ff2807e040804c2fa8a92a1da04844471a2 (diff) | |
| download | cpython-b212157465b82e97f5d9e5fdefafe933cb2c0487.zip cpython-b212157465b82e97f5d9e5fdefafe933cb2c0487.tar.gz cpython-b212157465b82e97f5d9e5fdefafe933cb2c0487.tar.bz2 | |
Additional test for __reduce__.
Diffstat (limited to 'Lib/test/test_collections.py')
| -rw-r--r-- | Lib/test/test_collections.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py index 60d4e0b..1800bec 100644 --- a/Lib/test/test_collections.py +++ b/Lib/test/test_collections.py @@ -728,6 +728,14 @@ class TestOrderedDict(unittest.TestCase): # '!!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_reduce_not_too_fat(self): + # do not save instance dictionary if not needed + pairs = [('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)] + od = OrderedDict(pairs) + self.assertEqual(len(od.__reduce__()), 2) + od.x = 10 + self.assertEqual(len(od.__reduce__()), 3) + def test_repr(self): od = OrderedDict([('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)]) self.assertEqual(repr(od), |
