MCPcopy Index your code
hub / github.com/RustPython/RustPython / _getAssertEqualityFunc

Method _getAssertEqualityFunc

Lib/unittest/case.py:892–916  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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."""

Callers 1

assertEqualMethod · 0.95

Calls 3

isinstanceFunction · 0.85
getattrFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected