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

Method _formatMessage

Lib/unittest/case.py:769–788  ·  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

767 raise self.failureException(msg)
768
769 def _formatMessage(self, msg, standardMsg):
770 """Honour the longMessage attribute when generating failure messages.
771 If longMessage is False this means:
772 * Use only an explicit message if it is provided
773 * Otherwise use the standard message for the assert
774
775 If longMessage is True:
776 * Use the standard message
777 * If an explicit message is provided, plus ' : ' and the explicit message
778 """
779 if not self.longMessage:
780 return msg or standardMsg
781 if msg is None:
782 return standardMsg
783 try:
784 # don't switch to '{}' formatting in Python 2.X
785 # it changes the way unicode input is handled
786 return '%s : %s' % (standardMsg, msg)
787 except UnicodeDecodeError:
788 return '%s : %s' % (safe_repr(standardMsg), safe_repr(msg))
789
790 def assertRaises(self, expected_exception, *args, **kwargs):
791 """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 12

_check_approx_seqMethod · 0.64
_check_approx_numMethod · 0.64
test_formatMsgMethod · 0.64
assertIsSubclassMethod · 0.64
assertNotIsSubclassMethod · 0.64
assertHasAttrMethod · 0.64
assertNotHasAttrMethod · 0.64
assertStartsWithMethod · 0.64
assertNotStartsWithMethod · 0.64
assertEndsWithMethod · 0.64
assertNotEndsWithMethod · 0.64