def run_suite(self, case): # Initialize the test class suite = case() # check test environment setup environ = TestEnviron(suite) methods = get_methods(suite, self.method_name) if not methods: return # Name the class class_name = suite.__class__.__name__ self.writer.out_case(class_name) # Are we skipping? if safe_skip_call(environ.set_skip_if): self.writer.skipping() return let_map = get_let_attrs(suite) # Set before all if any self.safe_environ_call(environ.set_before_all) for test in methods: test_start_time = StopWatch(raw=True) suite = set_let_attrs(suite, let_map) self.total_cases += 1 # Set before each if any self.safe_environ_call(environ.set_before_each) try: getattr(suite, test)() test_elapsed_time = Decimal(str(test_start_time.elapsed())) self.writer.green_spec(test) except BaseException, e: test_elapsed_time = Decimal(str(test_start_time.elapsed())) trace = inspect.trace()[-1] self.total_failures += 1 self.writer.red_spec(test) self.failures.append( dict( failure = sys.exc_info(), trace = trace, exc_name = e.__class__.__name__ ) ) if self.config.get('first_fail'): raise KoniraFirstFail # Save profiling info self.profiles.append((test_elapsed_time, test, class_name)) # Set after each if any self.safe_environ_call(environ.set_after_each)
def runtest(self): # check test environment setup environ = TestEnviron(self.case) # Set before each if any environ.set_before_each() case = set_let_attrs(self.case, self.let_attrs) getattr(case, self.spec)() # Set after each if any environ.set_after_each()
def __init__(self, name, parent, case, spec, let_attrs): super(KoniraItem, self).__init__(name, parent) self.spec = spec self.let_attrs = let_attrs self.case = set_let_attrs(case, let_attrs)
def run_suite(self, case): # Initialize the test class suite = case() # check test environment setup environ = TestEnviron(suite) methods = get_methods(suite, self.method_name) if not methods: return # Name the class class_name = suite.__class__.__name__ self.writer.out_case(class_name) # Are we skipping? if safe_skip_call(environ.set_skip_if): self.writer.skipping() return let_map = get_let_attrs(suite) # Set before all if any self.safe_environ_call(environ.set_before_all) for test in methods: test_start_time = StopWatch(raw=True) suite = set_let_attrs(suite, let_map) self.total_cases += 1 # Set before each if any self.safe_environ_call(environ.set_before_each) try: getattr(suite, test)() test_elapsed_time = Decimal(str(test_start_time.elapsed())) self.writer.green_spec(test) except BaseException, e: test_elapsed_time = Decimal(str(test_start_time.elapsed())) trace = inspect.trace()[-1] self.total_failures += 1 self.writer.red_spec(test) self.failures.append( dict(failure=sys.exc_info(), trace=trace, exc_name=e.__class__.__name__)) is_assert_error = isinstance(e, AssertionError) if is_assert_error and self.config.get('pdb_on_fail'): pdb_post_postmortem() elif not is_assert_error and self.config.get('pdb'): pdb_post_postmortem() if self.config.get('first_fail'): raise KoniraFirstFail # Save profiling info self.profiles.append((test_elapsed_time, test, class_name)) # Set after each if any self.safe_environ_call(environ.set_after_each)