How to test Django Signals like a pro
Haki Benita
1393

Thank you for a very elegant solution.

I needed to add signal=charge_completed to get the assert working correctly.

handler.assert_called_once_with(total=100, sender=mock.ANY, signal=charge_completed)

Also shouldn’t

with CatchSignal(signal) as handler:

be

with CatchSignal(charge_completed) as handler:

? — just for consistency.

And there are a few typos of no create concern. signal_kwrags should be signal_kwargs.

I really like all of your post — keep them coming please :)

Show your support

Clapping shows how much you appreciated Erik Svendsen Laustsen’s story.