File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Lib/unittest/test/testmock Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 4
4
5
5
import os
6
6
import sys
7
+ from collections import OrderedDict
7
8
8
9
import unittest
9
10
from unittest .test .testmock import support
@@ -1834,6 +1835,25 @@ def foo(*a, x=0):
1834
1835
self .assertEqual (foo (), 1 )
1835
1836
self .assertEqual (foo (), 0 )
1836
1837
1838
+ def test_patch_orderdict (self ):
1839
+ foo = OrderedDict ()
1840
+ foo ['a' ] = object ()
1841
+ foo ['b' ] = 'python'
1842
+
1843
+ original = foo .copy ()
1844
+ update_values = list (zip ('cdefghijklmnopqrstuvwxyz' , range (26 )))
1845
+ patched_values = list (foo .items ()) + update_values
1846
+
1847
+ with patch .dict (foo , OrderedDict (update_values )):
1848
+ self .assertEqual (list (foo .items ()), patched_values )
1849
+
1850
+ self .assertEqual (foo , original )
1851
+
1852
+ with patch .dict (foo , update_values ):
1853
+ self .assertEqual (list (foo .items ()), patched_values )
1854
+
1855
+ self .assertEqual (foo , original )
1856
+
1837
1857
def test_dotted_but_module_not_loaded (self ):
1838
1858
# This exercises the AttributeError branch of _dot_lookup.
1839
1859
You can’t perform that action at this time.
0 commit comments