Given a call (or simply an (args, kwargs) tuple), return a comparison key suitable for matching with other calls. This is a best effort method which relies on the spec's signature, if available, or falls back on the arguments themselves.
(self, _call)
| 910 | |
| 911 | |
| 912 | def _call_matcher(self, _call): |
| 913 | """ |
| 914 | Given a call (or simply an (args, kwargs) tuple), return a |
| 915 | comparison key suitable for matching with other calls. |
| 916 | This is a best effort method which relies on the spec's signature, |
| 917 | if available, or falls back on the arguments themselves. |
| 918 | """ |
| 919 | |
| 920 | if isinstance(_call, tuple) and len(_call) > 2: |
| 921 | sig = self._get_call_signature_from_name(_call[0]) |
| 922 | else: |
| 923 | sig = self._spec_signature |
| 924 | |
| 925 | if sig is not None: |
| 926 | if len(_call) == 2: |
| 927 | name = '' |
| 928 | args, kwargs = _call |
| 929 | else: |
| 930 | name, args, kwargs = _call |
| 931 | try: |
| 932 | bound_call = sig.bind(*args, **kwargs) |
| 933 | return call(name, bound_call.args, bound_call.kwargs) |
| 934 | except TypeError as e: |
| 935 | return e.with_traceback(None) |
| 936 | else: |
| 937 | return _call |
| 938 | |
| 939 | def assert_not_called(self): |
| 940 | """assert that the mock was never called. |
no test coverage detected