Commit 5a718e91 authored by Anthony Sottile's avatar Anthony Sottile Committed by Chris Withers

Add test for double patching instance methods (#11085)

parent f7fa62ef
......@@ -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):
......
Added test demonstrating double-patching of an instance method. Patch by
Anthony Sottile.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment