1👍
✅
Got it working by doing the patching a bit differently:
@mock.patch('donations.views.CreditCardForm.create_card')
@mock.patch('donations.views.CreditCardForm.charge_customer')
def test_foo(self, mock_charge_customer, mock_create_card):
mock_create_card.return_value = True
mock_charge_customer.return_value = MagicMock(id='abc123')
# remainder of code
Now the id matches what I expect. I’d still like to know what I did wrong on the previous code though.
Source:stackexchange.com