Override few magic functions in return object
define equality, mark object as unhashable again as it is mutable.
Markus Gerstel
4 years ago
362 | 362 | self.stdout = self["stdout"] |
363 | 363 | self.stderr = self["stderr"] |
364 | 364 | |
365 | def __eq__(self, other): | |
366 | """Override equality operator to account for added fields""" | |
367 | if type(other) is type(self): | |
368 | return self.__dict__ == other.__dict__ | |
369 | return False | |
370 | ||
371 | def __hash__(self): | |
372 | """This object is not immutable, so mark it as unhashable""" | |
373 | return None | |
374 | ||
375 | def __ne__(self, other): | |
376 | """Overrides the default implementation (unnecessary in Python 3)""" | |
377 | return not self.__eq__(other) | |
378 | ||
365 | 379 | |
366 | 380 | def run( |
367 | 381 | command, |