Consider the following example:
import unittest
class MessageExampleTest(unittest.TestCase):
def test_with_default_message(self):
self.assertEqual('apples', 'oranges')
def test_with_custom_message(self):
self.assertEqual('apples', 'oranges', 'You should not compare apples and oranges.')
Output:
======================================================================
FAIL: test_with_default_message (assert_message.MessageExampleTest)
----------------------------------------------------------------------
Traceback (most recent call last):
...
self.assertEqual('apples', 'oranges')
AssertionError: 'apples' != 'oranges'
======================================================================
FAIL: test_with_custom_message (assert_message.MessageExampleTest)
----------------------------------------------------------------------
Traceback (most recent call last):
...
self.assertEqual('apples', 'oranges', 'You should not compare apples and oranges.')
AssertionError: You should not compare apples and oranges.
----------------------------------------------------------------------
What I'd like to see, in the second case, is something like:
AssertionError: 'apples' != 'oranges'; You should not compare apples and oranges.
Aucun commentaire:
Enregistrer un commentaire