mirror of https://github.com/python/cpython
Add test for double patching instance methods (#11085)
This commit is contained in:
parent
f7fa62ef44
commit
5a718e918d
|
@ -126,6 +126,20 @@ class WithTest(unittest.TestCase):
|
|||
|
||||
self.assertEqual(foo, {})
|
||||
|
||||
def test_double_patch_instance_method(self):
|
||||
class C:
|
||||
def f(self):
|
||||
pass
|
||||
|
||||
c = C()
|
||||
|
||||
with patch.object(c, 'f', autospec=True) as patch1:
|
||||
with patch.object(c, 'f', autospec=True) as patch2:
|
||||
c.f()
|
||||
self.assertEqual(patch2.call_count, 1)
|
||||
self.assertEqual(patch1.call_count, 0)
|
||||
c.f()
|
||||
self.assertEqual(patch1.call_count, 1)
|
||||
|
||||
|
||||
class TestMockOpen(unittest.TestCase):
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Added test demonstrating double-patching of an instance method. Patch by
|
||||
Anthony Sottile.
|
Loading…
Reference in New Issue