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)
with CatchSignal(signal) as handler:
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 :)