Created
November 25, 2015 22:12
-
-
Save behrtam/3fe4c75bcee4a02c5953 to your computer and use it in GitHub Desktop.
"This method is used by default when comparing strings with assertEqual()." https://docs.python.org/2/library/unittest.html?highlight=unittest#unittest.TestCase.assertMultiLineEqual
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
class AssertTests(unittest.TestCase): | |
def testAssertEqual(self): | |
self.assertEqual('ABCD', 'ABC') | |
def testAssertMultiLineEqual(self): | |
self.assertMultiLineEqual('ABCD', 'ABC') | |
if __name__ == '__main__': | |
unittest.main() | |
''' # OUTPUT | |
$ python2.7 asserttest.py | |
FF | |
====================================================================== | |
FAIL: test_one (__main__.AssertTests) | |
---------------------------------------------------------------------- | |
Traceback (most recent call last): | |
File "asserttest.py", line 6, in test_one | |
self.assertEqual('ABCD', 'ABC') | |
AssertionError: 'ABCD' != 'ABC' | |
====================================================================== | |
FAIL: test_transcribes_all_occurences (__main__.AssertTests) | |
---------------------------------------------------------------------- | |
Traceback (most recent call last): | |
File "asserttest.py", line 9, in test_transcribes_all_occurences | |
self.assertMultiLineEqual('ABCD', 'ABC') | |
AssertionError: 'ABCD' != 'ABC' | |
- ABCD | |
? - | |
+ ABC | |
---------------------------------------------------------------------- | |
Ran 2 tests in 0.001s | |
FAILED (failures=2) | |
$ python3.5 asserttest.py | |
FF | |
====================================================================== | |
FAIL: test_one (__main__.AssertTests) | |
---------------------------------------------------------------------- | |
Traceback (most recent call last): | |
File "asserttest.py", line 6, in test_one | |
self.assertEqual('ABCD', 'ABC') | |
AssertionError: 'ABCD' != 'ABC' | |
- ABCD | |
? - | |
+ ABC | |
====================================================================== | |
FAIL: test_transcribes_all_occurences (__main__.AssertTests) | |
---------------------------------------------------------------------- | |
Traceback (most recent call last): | |
File "asserttest.py", line 9, in test_transcribes_all_occurences | |
self.assertMultiLineEqual('ABCD', 'ABC') | |
AssertionError: 'ABCD' != 'ABC' | |
- ABCD | |
? - | |
+ ABC | |
---------------------------------------------------------------------- | |
Ran 2 tests in 0.001s | |
FAILED (failures=2) | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment