Logo Search packages:      
Sourcecode: mago version File versions  Download package

def mago::cmd::runner::TestCaseRunner::run (   self,
  logger 
)

Run test case and gather results

Definition at line 25 of file runner.py.

00025                          :
        """
        Run test case and gather results
        """
        logging.info("Running test case '%s' (%s)"
                     % (self.case_data.name,
                        self.case_data.methodname))
        starttime = time()
        try:
            rv = self.test_method(**self.case_data.args)
        except AssertionError, e:
            # The test failed.
            if len(e.args) > 1:
                self.results.append('message', e.args[0])
                self.results.append_screenshot(e.args[1])
            else:
                self.results.append('message', str(e))
                self.results.append_screenshot()
            self.results.append('stacktrace', traceback.format_exc())
            self.results['pass'] = 0
        except Exception, e:
            # There was an unrelated error.
            logging.warning(traceback.format_exc())
            if len(e.args) > 1 and os.path.exists(e.args[1]):
                self.results.append('message', e.args[0])
                self.results.append_screenshot(e.args[1])
            else:
                self.results.append('message', str(e))
                self.results.append_screenshot()
            self.results.append('stacktrace', traceback.format_exc())
            self.results['error'] = 1
        else:
            self.results['pass'] = 1
            try:
                message, screenshot = rv
            except:
                pass
            else:
                if message:
                    self.results.append('message', message)
                if screenshot:
                    self.results.append_screenshot(screenshot)
        finally:
            self.results['time'] = time() - starttime
        
        self.case_data.add_results(self.results)

        
class TestSuiteRunner:


Generated by  Doxygen 1.6.0   Back to index