def startTest(self, test): # we want to change the ResultProxy object, not just the result, # therefore we do it here, not in prepareTestResult rp = test.test._resultForDoCleanups # we store the original func rp._ml_add_success = rp.addSuccess # and replace it rp.addSuccess = make_instancemethod(_MemleakResult.addSuccess, rp) # also add a default failure flag rp._ml_is_success = False # Finally, we store with the test the names that it has at birth, # so that we only wipe stuff created during the test. test._mda_pretest_attrs = test.test.__dict__.keys()
def add_skip_patch(result): """Create a new addSkip method to patch into a result instance that delegates to addError. """ return make_instancemethod(TextTestResult.addSkip, result)
def wassuccessful_patch(result): """Create a new wasSuccessful method that checks errorClasses for exceptions that were put into other slots than error or failure but that still count as not success. """ return make_instancemethod(TextTestResult.wasSuccessful, result)
def print_label_patch(result): """Create a new printLabel method that prints errorClasses items as well. """ return make_instancemethod(TextTestResult.printLabel, result)
def add_error_patch(result): """Create a new addError method to patch into a result instance that recognizes the errorClasses attribute and deals with errorclasses correctly. """ return make_instancemethod(TextTestResult.addError, result)