Python functools.partial
instances bind the function before monkeypatch can get at the function.
This makes patching them out difficult and tedious.
This fixture finds all partials in a module and replaces them with MagicMocks then yields the MagicMock to assert against.
This might be useful if the partials were calls to an API or service where we just want to make sure a call was made.
In my actual case these were calls to publish to various AWS SNS topics. The partials populate the topic ARN from an imported environment variable. I felt it sufficient to test that one of the calls was used rather than patch each one individually.
I think the code should run, but I've only actually run the fixture, the rest is just an example I wrote in gist to explain it.