diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-12-18 19:22:50 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-12-18 19:22:50 (GMT) |
commit | 7bfe89945b6960bb68e27fd25fea421eee9b1fca (patch) | |
tree | 9f479b4beec9e5dc6bc6365df1a2bd29ae74c860 /Lib/doctest.py | |
parent | 83250bb0a80cd7b5f5024965d4a71790de8b25df (diff) | |
parent | 165b1283ffe5922dd9f64ef7edb5534e6983d2f5 (diff) | |
download | cpython-7bfe89945b6960bb68e27fd25fea421eee9b1fca.zip cpython-7bfe89945b6960bb68e27fd25fea421eee9b1fca.tar.gz cpython-7bfe89945b6960bb68e27fd25fea421eee9b1fca.tar.bz2 |
Followup to #7502: add __hash__ method and tests.
Diffstat (limited to 'Lib/doctest.py')
-rw-r--r-- | Lib/doctest.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/doctest.py b/Lib/doctest.py index 5d315cc..aba98dc 100644 --- a/Lib/doctest.py +++ b/Lib/doctest.py @@ -454,6 +454,9 @@ class Example: def __ne__(self, other): return not self == other + def __hash__(self): + return hash((self.source, self.want, self.lineno, self.indent, + self.exc_msg)) class DocTest: """ @@ -517,6 +520,9 @@ class DocTest: def __ne__(self, other): return not self == other + def __hash__(self): + return hash((self.docstring, self.name, self.filename, self.lineno)) + # This lets us sort tests by name: def __lt__(self, other): if not isinstance(other, DocTest): @@ -2247,6 +2253,10 @@ class DocTestCase(unittest.TestCase): def __ne__(self, other): return not self == other + def __hash__(self): + return hash((self._dt_optionflags, self._dt_setUp, self._dt_tearDown, + self._dt_checker)) + def __repr__(self): name = self._dt_test.name.split('.') return "%s (%s)" % (name[-1], '.'.join(name[:-1])) |