diff options
author | Emmanuel Arias <eamanu@yaerobi.com> | 2020-01-24 08:14:14 (GMT) |
---|---|---|
committer | Chris Withers <chris@withers.org> | 2020-01-24 08:14:14 (GMT) |
commit | 1d0c5e16eab29d55773cc4196bb90d2bf12e09dd (patch) | |
tree | 3af07df180446b2416e47213a572ec87036a4cba /Lib/unittest | |
parent | 65ecc390c1fa5acdd6348ae3f9843bbdcd8870d1 (diff) | |
download | cpython-1d0c5e16eab29d55773cc4196bb90d2bf12e09dd.zip cpython-1d0c5e16eab29d55773cc4196bb90d2bf12e09dd.tar.gz cpython-1d0c5e16eab29d55773cc4196bb90d2bf12e09dd.tar.bz2 |
bpo-24928: Add test case for patch.dict using OrderedDict (GH -11437)
* add test for path.dict using OrderedDict
Co-authored-by: Yu Tomita nekobon@users.noreply.github.com
Diffstat (limited to 'Lib/unittest')
-rw-r--r-- | Lib/unittest/test/testmock/testpatch.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/unittest/test/testmock/testpatch.py b/Lib/unittest/test/testmock/testpatch.py index e065a2c..dc4ccdb 100644 --- a/Lib/unittest/test/testmock/testpatch.py +++ b/Lib/unittest/test/testmock/testpatch.py @@ -4,6 +4,7 @@ import os import sys +from collections import OrderedDict import unittest from unittest.test.testmock import support @@ -1834,6 +1835,25 @@ class PatchTest(unittest.TestCase): self.assertEqual(foo(), 1) self.assertEqual(foo(), 0) + def test_patch_orderdict(self): + foo = OrderedDict() + foo['a'] = object() + foo['b'] = 'python' + + original = foo.copy() + update_values = list(zip('cdefghijklmnopqrstuvwxyz', range(26))) + patched_values = list(foo.items()) + update_values + + with patch.dict(foo, OrderedDict(update_values)): + self.assertEqual(list(foo.items()), patched_values) + + self.assertEqual(foo, original) + + with patch.dict(foo, update_values): + self.assertEqual(list(foo.items()), patched_values) + + self.assertEqual(foo, original) + def test_dotted_but_module_not_loaded(self): # This exercises the AttributeError branch of _dot_lookup. |