summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_doctest.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-12-18 19:22:50 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2011-12-18 19:22:50 (GMT)
commit7bfe89945b6960bb68e27fd25fea421eee9b1fca (patch)
tree9f479b4beec9e5dc6bc6365df1a2bd29ae74c860 /Lib/test/test_doctest.py
parent83250bb0a80cd7b5f5024965d4a71790de8b25df (diff)
parent165b1283ffe5922dd9f64ef7edb5534e6983d2f5 (diff)
downloadcpython-7bfe89945b6960bb68e27fd25fea421eee9b1fca.zip
cpython-7bfe89945b6960bb68e27fd25fea421eee9b1fca.tar.gz
cpython-7bfe89945b6960bb68e27fd25fea421eee9b1fca.tar.bz2
Followup to #7502: add __hash__ method and tests.
Diffstat (limited to 'Lib/test/test_doctest.py')
-rw-r--r--Lib/test/test_doctest.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py
index ac79e02..cdcd389 100644
--- a/Lib/test/test_doctest.py
+++ b/Lib/test/test_doctest.py
@@ -259,6 +259,21 @@ unless it's `None`:
>>> e = doctest.Example('raise X()', '', exc_msg)
>>> e.exc_msg
'\n'
+
+Compare `Example`:
+ >>> example = doctest.Example('print 1', '1\n')
+ >>> same_example = doctest.Example('print 1', '1\n')
+ >>> other_example = doctest.Example('print 42', '42\n')
+ >>> example == same_example
+ True
+ >>> example != same_example
+ False
+ >>> hash(example) == hash(same_example)
+ True
+ >>> example == other_example
+ False
+ >>> example != other_example
+ True
"""
def test_DocTest(): r"""
@@ -362,6 +377,8 @@ Compare `DocTest`:
True
>>> test != same_test
False
+ >>> hash(test) == hash(same_test)
+ True
>>> docstring = '''
... >>> print 42
... 42
@@ -383,6 +400,8 @@ Compare `DocTestCase`:
True
>>> test_case != same_test_case
False
+ >>> hash(test_case) == hash(same_test_case)
+ True
>>> test == other_test_case
False
>>> test != other_test_case