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:
"""
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):
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]))
>>> 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"""
True
>>> test != same_test
False
+ >>> hash(test) == hash(same_test)
+ True
>>> docstring = '''
... >>> print 42
... 42
True
>>> test_case != same_test_case
False
+ >>> hash(test_case) == hash(same_test_case)
+ True
>>> test == other_test_case
False
>>> test != other_test_case