I have found that the python internal deals with dictionary object different as the other object like function and list.
Does anyone have idea why python mock library (1.0.1) has a patch.dict specifically besides the existing patch and patch.object?
patch.dict()
for setting values in a dictionary just during a scope and restoring the dictionary to its original state when the test ends:
foo = {'key': 'value'}
original = foo.copy()
with patch.dict(foo, {'newkey': 'newvalue'}, clear=True):
assert foo == {'newkey': 'newvalue'}
assert foo == original
See the reference for further info.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With