def test_patch_idempotency(self, _w): # Ensure we didn't do any patching automatically _w.assert_not_called() self.assert_is_not_patched() # Patch for the first time patch() _w.assert_called() self.assert_is_patched() # Reset the mock so we can assert call count _w.reset_mock() # Call patch a second time patch() _w.assert_not_called() self.assert_is_patched()
def test_unpatch_idempotency(self, _u, _w): # We need to patch in order to unpatch patch() _w.assert_called() self.assert_is_patched() # Ensure we didn't do any unpatching automatically _u.assert_not_called() unpatch() _u.assert_called() self.assert_is_not_patched() # Reset the mock so we can assert call count _u.reset_mock() # Call unpatch a second time unpatch() _u.assert_not_called() self.assert_is_not_patched()