Skip to content

Commit ac85476

Browse files
committed
Add TestOrderedDict from 3.2
1 parent 1a469d7 commit ac85476

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

test_functools32.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from weakref import proxy
77
import pickle
88
from random import choice
9+
from functools32 import OrderedDict
910

1011
@staticmethod
1112
def PythonPartial(func, *args, **keywords):
@@ -671,6 +672,21 @@ def func(i):
671672
with self.assertRaises(IndexError):
672673
func(15)
673674

675+
class TestOrderedDict(unittest.TestCase):
676+
def test_move_to_end(self):
677+
od = OrderedDict.fromkeys('abcde')
678+
self.assertEqual(list(od), list('abcde'))
679+
od.move_to_end('c')
680+
self.assertEqual(list(od), list('abdec'))
681+
od.move_to_end('c', 0)
682+
self.assertEqual(list(od), list('cabde'))
683+
od.move_to_end('c', 0)
684+
self.assertEqual(list(od), list('cabde'))
685+
od.move_to_end('e')
686+
self.assertEqual(list(od), list('cabde'))
687+
with self.assertRaises(KeyError):
688+
od.move_to_end('x')
689+
674690
def test_main(verbose=None):
675691
test_classes = (
676692
TestPartial,
@@ -682,6 +698,7 @@ def test_main(verbose=None):
682698
TestWraps,
683699
TestReduce,
684700
TestLRU,
701+
TestOrderedDict,
685702
)
686703
support.run_unittest(*test_classes)
687704

0 commit comments

Comments
 (0)