New submission from valkheim <valkh...@protonmail.com>:
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 ---------- messages: 354770 nosy: valkheim priority: normal severity: normal status: open title: Add assert_not_called_with type: enhancement _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue38494> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com