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)
| 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 |