This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author valkheim
Recipients valkheim
Date 2019-10-16.06:22:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1571206970.26.0.707248566898.issue38494@roundup.psfhosted.org>
In-reply-to
Content
This would be nice to integrate an assert_not_called_with feature.

I had to implement it to test a publish/subscribe patterns where multiple subscibers got called but not with the same arguments.

Here is my implementation:

```
def assert_not_called_with(self, *args, **kwargs):
    """assert that the mock was never called with the specified arguments.
    """
    try:
        self.assert_called_with(*args, **kwargs)
    except AssertionError:
        return
    raise AssertionError(
        "Expected %s to not have been called."
        % self._format_mock_call_signature(args, kwargs)
    )
```

An alternative would had been to iterate the call_args_list but it wouldn't result in a clean one-line assert

coming from: https://github.com/testing-cabal/mock/issues/473
History
Date User Action Args
2019-10-16 06:22:50valkheimsetrecipients: + valkheim
2019-10-16 06:22:50valkheimsetmessageid: <1571206970.26.0.707248566898.issue38494@roundup.psfhosted.org>
2019-10-16 06:22:50valkheimlinkissue38494 messages
2019-10-16 06:22:50valkheimcreate