Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Lib/unittest/test/testmock/testwith.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,20 @@ def test_dict_context_manager(self):

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):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Added test demonstrating double-patching of an instance method. Patch by
Anthony Sottile.