* If call objects are asserted against a method/function like obj.meth1 then there could be no name for the call object to lookup. Hence just return the spec_signature of the method/function being asserted against. * If the name is not empty then remove () and split
(self, name)
| 876 | |
| 877 | |
| 878 | def _get_call_signature_from_name(self, name): |
| 879 | """ |
| 880 | * If call objects are asserted against a method/function like obj.meth1 |
| 881 | then there could be no name for the call object to lookup. Hence just |
| 882 | return the spec_signature of the method/function being asserted against. |
| 883 | * If the name is not empty then remove () and split by '.' to get |
| 884 | list of names to iterate through the children until a potential |
| 885 | match is found. A child mock is created only during attribute access |
| 886 | so if we get a _SpecState then no attributes of the spec were accessed |
| 887 | and can be safely exited. |
| 888 | """ |
| 889 | if not name: |
| 890 | return self._spec_signature |
| 891 | |
| 892 | sig = None |
| 893 | names = name.replace('()', '').split('.') |
| 894 | children = self._mock_children |
| 895 | |
| 896 | for name in names: |
| 897 | child = children.get(name) |
| 898 | if child is None or isinstance(child, _SpecState): |
| 899 | break |
| 900 | else: |
| 901 | # If an autospecced object is attached using attach_mock the |
| 902 | # child would be a function with mock object as attribute from |
| 903 | # which signature has to be derived. |
| 904 | child = _extract_mock(child) |
| 905 | children = child._mock_children |
| 906 | sig = child._spec_signature |
| 907 | |
| 908 | return sig |
| 909 | |
| 910 | |
| 911 | def _call_matcher(self, _call): |
no test coverage detected