MCPcopy Index your code
hub / github.com/python/cpython / _formatMessage

Method _formatMessage

Lib/unittest/case.py:762–781  ·  view source on GitHub ↗

Honour the longMessage attribute when generating failure messages. If longMessage is False this means: * Use only an explicit message if it is provided * Otherwise use the standard message for the assert If longMessage is True: * Use the standard message

(self, msg, standardMsg)

Source from the content-addressed store, hash-verified

760 raise self.failureException(msg)
761
762 def _formatMessage(self, msg, standardMsg):
763 """Honour the longMessage attribute when generating failure messages.
764 If longMessage is False this means:
765 * Use only an explicit message if it is provided
766 * Otherwise use the standard message for the assert
767
768 If longMessage is True:
769 * Use the standard message
770 * If an explicit message is provided, plus ' : ' and the explicit message
771 """
772 if not self.longMessage:
773 return msg or standardMsg
774 if msg is None:
775 return standardMsg
776 try:
777 # don't switch to '{}' formatting in Python 2.X
778 # it changes the way unicode input is handled
779 return '%s : %s' % (standardMsg, msg)
780 except UnicodeDecodeError:
781 return '%s : %s' % (safe_repr(standardMsg), safe_repr(msg))
782
783 def assertRaises(self, expected_exception, *args, **kwargs):
784 """Fail unless an exception of class expected_exception is raised

Callers 15

assertFalseMethod · 0.95
assertTrueMethod · 0.95
_baseAssertEqualMethod · 0.95
assertNotEqualMethod · 0.95
assertAlmostEqualMethod · 0.95
assertNotAlmostEqualMethod · 0.95
assertSequenceEqualMethod · 0.95
assertSetEqualMethod · 0.95
assertInMethod · 0.95
assertNotInMethod · 0.95
assertIsMethod · 0.95
assertIsNotMethod · 0.95

Calls 1

safe_reprFunction · 0.85

Tested by 5

_check_approx_seqMethod · 0.64
_check_approx_numMethod · 0.64
test_formatMsgMethod · 0.64
assert_ns_equalMethod · 0.64