← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #242649]: Take Screenshot for pass case also

 

Question #242649 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/242649

RaiMan proposed the following answer:
HTMLTestRunner is an "extension" of the normal Python unittest
TextTestRunner.

So it only comes into existence/usage if you have organised your stuff in test suites and or test cases.
I assume, you are doing that.

The HTMLTestRunner, that saves screenshots on test fail (a test function
terminates with assert false) is a modification I have done on the
original HTMLTestrunner. I assume this is the one you use.

This is the modification I made to get the shot at failure: (line 629)

    def addFailure(self, test, err):
        self.failure_count += 1
        TestResult.addFailure(self, test, err)
        _, _exc_str = self.failures[-1]
        output = self.complete_output()
        self.result.append((1, test, output, _exc_str, self.generateTestScreenshot(test))) # modified by RaiMan
        if self.verbosity > 1:
            sys.stderr.write('F  ')
            sys.stderr.write(str(test))
            sys.stderr.write('\n')
        else:
            sys.stderr.write('F')

there are the 2 other functions for error (some Python error not being
assert false) and success (assert true):

line 616
    def addError(self, test, err):
...

line 604
    def addSuccess(self, test):

these functions need the same modification, to get a shot in any case
supported by unittest.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.