summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_doctest.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-12-18 18:27:45 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2011-12-18 18:27:45 (GMT)
commit2bc801c4ea7b47d4b6db49e0ac0d9e0b3cfef010 (patch)
tree773175e5a4cf9d1518ad541e58a0bf9487b526d0 /Lib/test/test_doctest.py
parentcf53ae2171d01eed0e1c902b51da27b5bdfbc143 (diff)
downloadcpython-2bc801c4ea7b47d4b6db49e0ac0d9e0b3cfef010.zip
cpython-2bc801c4ea7b47d4b6db49e0ac0d9e0b3cfef010.tar.gz
cpython-2bc801c4ea7b47d4b6db49e0ac0d9e0b3cfef010.tar.bz2
Issue #7502: Fix equality comparison for DocTestCase instances.
Patch by Cédric Krier.
Diffstat (limited to 'Lib/test/test_doctest.py')
-rw-r--r--Lib/test/test_doctest.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py
index 13836ba..676d5de 100644
--- a/Lib/test/test_doctest.py
+++ b/Lib/test/test_doctest.py
@@ -347,6 +347,46 @@ will raise a ValueError:
Traceback (most recent call last):
ValueError: line 2 of the docstring for some_test lacks blank after ...: '...print(1)'
+Compare `DocTest`:
+
+ >>> docstring = '''
+ ... >>> print 12
+ ... 12
+ ... '''
+ >>> test = parser.get_doctest(docstring, globs, 'some_test',
+ ... 'some_test', 20)
+ >>> same_test = parser.get_doctest(docstring, globs, 'some_test',
+ ... 'some_test', 20)
+ >>> test == same_test
+ True
+ >>> test != same_test
+ False
+ >>> docstring = '''
+ ... >>> print 42
+ ... 42
+ ... '''
+ >>> other_test = parser.get_doctest(docstring, globs, 'other_test',
+ ... 'other_file', 10)
+ >>> test == other_test
+ False
+ >>> test != other_test
+ True
+
+Compare `DocTestCase`:
+
+ >>> DocTestCase = doctest.DocTestCase
+ >>> test_case = DocTestCase(test)
+ >>> same_test_case = DocTestCase(same_test)
+ >>> other_test_case = DocTestCase(other_test)
+ >>> test_case == same_test_case
+ True
+ >>> test_case != same_test_case
+ False
+ >>> test == other_test_case
+ False
+ >>> test != other_test_case
+ True
+
"""
def test_DocTestFinder(): r"""