@@ -440,6 +440,21 @@ def __init__(self, source, want, exc_msg=None, lineno=0, indent=0,
440440 self .options = options
441441 self .exc_msg = exc_msg
442442
443+ def __eq__ (self , other ):
444+ if type (self ) is not type (other ):
445+ return NotImplemented
446+
447+ return self .source == other .source and \
448+ self .want == other .want and \
449+ self .lineno == other .lineno and \
450+ self .indent == other .indent and \
451+ self .options == other .options and \
452+ self .exc_msg == other .exc_msg
453+
454+ def __ne__ (self , other ):
455+ return not self == other
456+
457+
443458class DocTest :
444459 """
445460 A collection of doctest examples that should be run in a single
@@ -488,6 +503,19 @@ def __repr__(self):
488503 return ('<DocTest %s from %s:%s (%s)>' %
489504 (self .name , self .filename , self .lineno , examples ))
490505
506+ def __eq__ (self , other ):
507+ if type (self ) is not type (other ):
508+ return NotImplemented
509+
510+ return self .examples == other .examples and \
511+ self .docstring == other .docstring and \
512+ self .globs == other .globs and \
513+ self .name == other .name and \
514+ self .filename == other .filename and \
515+ self .lineno == other .lineno
516+
517+ def __ne__ (self , other ):
518+ return not self == other
491519
492520 # This lets us sort tests by name:
493521 def __lt__ (self , other ):
@@ -2204,6 +2232,19 @@ def debug(self):
22042232 def id (self ):
22052233 return self ._dt_test .name
22062234
2235+ def __eq__ (self , other ):
2236+ if type (self ) is not type (other ):
2237+ return NotImplemented
2238+
2239+ return self ._dt_test == other ._dt_test and \
2240+ self ._dt_optionflags == other ._dt_optionflags and \
2241+ self ._dt_setUp == other ._dt_setUp and \
2242+ self ._dt_tearDown == other ._dt_tearDown and \
2243+ self ._dt_checker == other ._dt_checker
2244+
2245+ def __ne__ (self , other ):
2246+ return not self == other
2247+
22072248 def __repr__ (self ):
22082249 name = self ._dt_test .name .split ('.' )
22092250 return "%s (%s)" % (name [- 1 ], '.' .join (name [:- 1 ]))
0 commit comments