summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_ordered_dict.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-10-30 15:25:45 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-10-30 15:25:45 (GMT)
commitb7d14a09c245f1e78911208b7f65bd09d7c03f2c (patch)
tree875ae469993805b05545c3653664db4667d73e88 /Lib/test/test_ordered_dict.py
parent944078786797b03b415d76b0b2d7f3fb8570b9a4 (diff)
parent043868393969224947c03617475d31f64ea59634 (diff)
downloadcpython-b7d14a09c245f1e78911208b7f65bd09d7c03f2c.zip
cpython-b7d14a09c245f1e78911208b7f65bd09d7c03f2c.tar.gz
cpython-b7d14a09c245f1e78911208b7f65bd09d7c03f2c.tar.bz2
Merge from 3.5.
Diffstat (limited to 'Lib/test/test_ordered_dict.py')
-rw-r--r--Lib/test/test_ordered_dict.py59
1 files changed, 0 insertions, 59 deletions
diff --git a/Lib/test/test_ordered_dict.py b/Lib/test/test_ordered_dict.py
index 582ff56..a35ed12 100644
--- a/Lib/test/test_ordered_dict.py
+++ b/Lib/test/test_ordered_dict.py
@@ -775,64 +775,5 @@ class CPythonSubclassMappingTests(mapping_tests.BasicTestMappingProtocol):
self.assertRaises(KeyError, d.popitem)
-class SimpleLRUCache:
-
- def __init__(self, size):
- super().__init__()
- self.size = size
-
- def __getitem__(self, item):
- value = super().__getitem__(item)
- self.move_to_end(item)
- return value
-
- def __setitem__(self, key, value):
- while key not in self and len(self) >= self.size:
- self.popitem(last=False)
- super().__setitem__(key, value)
- self.move_to_end(key)
-
-
-class SimpleLRUCacheTests:
-
- def test_add_after_full(self):
- c = self.type2test(2)
- c['t1'] = 1
- c['t2'] = 2
- c['t3'] = 3
- self.assertEqual(list(c), ['t2', 't3'])
-
- def test_popitem(self):
- c = self.type2test(3)
- for i in range(1, 4):
- c[i] = i
- self.assertEqual(c.popitem(last=False), (1, 1))
- self.assertEqual(c.popitem(last=True), (3, 3))
-
- def test_change_order_on_get(self):
- c = self.type2test(3)
- for i in range(1, 4):
- c[i] = i
- self.assertEqual(list(c), list(range(1, 4)))
- self.assertEqual(c[2], 2)
- self.assertEqual(list(c), [1, 3, 2])
-
-
-class PySimpleLRUCacheTests(SimpleLRUCacheTests, unittest.TestCase):
-
- class type2test(SimpleLRUCache, py_coll.OrderedDict):
- pass
-
-
-@unittest.skipUnless(c_coll, 'requires the C version of the collections module')
-class CSimpleLRUCacheTests(SimpleLRUCacheTests, unittest.TestCase):
-
- @classmethod
- def setUpClass(cls):
- class type2test(SimpleLRUCache, c_coll.OrderedDict):
- pass
- cls.type2test = type2test
-
-
if __name__ == "__main__":
unittest.main()