Get a detailed comparison function for the types of the two args. Returns: A callable accepting (first, second, msg=None) that will raise a failure exception if first != second with a useful human readable error message for those types.
(self, first, second)
| 890 | return _AssertLogsContext(self, logger, level, no_logs=True) |
| 891 | |
| 892 | def _getAssertEqualityFunc(self, first, second): |
| 893 | """Get a detailed comparison function for the types of the two args. |
| 894 | |
| 895 | Returns: A callable accepting (first, second, msg=None) that will |
| 896 | raise a failure exception if first != second with a useful human |
| 897 | readable error message for those types. |
| 898 | """ |
| 899 | # |
| 900 | # NOTE(gregory.p.smith): I considered isinstance(first, type(second)) |
| 901 | # and vice versa. I opted for the conservative approach in case |
| 902 | # subclasses are not intended to be compared in detail to their super |
| 903 | # class instances using a type equality func. This means testing |
| 904 | # subtypes won't automagically use the detailed comparison. Callers |
| 905 | # should use their type specific assertSpamEqual method to compare |
| 906 | # subclasses if the detailed comparison is desired and appropriate. |
| 907 | # See the discussion in http://bugs.python.org/issue2578. |
| 908 | # |
| 909 | if type(first) is type(second): |
| 910 | asserter = self._type_equality_funcs.get(type(first)) |
| 911 | if asserter is not None: |
| 912 | if isinstance(asserter, str): |
| 913 | asserter = getattr(self, asserter) |
| 914 | return asserter |
| 915 | |
| 916 | return self._baseAssertEqual |
| 917 | |
| 918 | def _baseAssertEqual(self, first, second, msg=None): |
| 919 | """The default assertEqual implementation, not type specific.""" |
no test coverage detected