def run(self): """ Find and load step definitions, and them find and load features under `base_path` specified on constructor """ results = [] if self.single_feature: features_files = [self.single_feature] else: features_files = self.loader.find_feature_files() if self.random: random.shuffle(features_files) if not features_files: self.output.print_no_features_found(self.loader.base_dir) return # only load steps if we've located some features. # this prevents stupid bugs when loading django modules # that we don't even want to test. try: self.loader.find_and_load_step_definitions() except StepLoadingError as e: print("Error loading step definitions:\n", e) return call_hook('before', 'all') failed = False try: for filename in features_files: feature = Feature.from_file(filename) results.append( feature.run(self.scenarios, tags=self.tags, random=self.random, failfast=self.failfast)) except exceptions.LettuceSyntaxError as e: sys.stderr.write(e.msg) failed = True except: if not self.failfast: e = sys.exc_info()[1] print("Died with %s" % str(e)) traceback.print_exc() else: print("Lettuce aborted running any more tests " "because was called with the `--failfast` option") failed = True finally: total = TotalResult(results) total.output_format() call_hook('after', 'all', total) if failed: raise SystemExit(2) return total
return failed = False try: for filename in features_files: feature = Feature.from_file(filename) results.append(feature.run(self.scenarios)) except exceptions.LettuceSyntaxError, e: sys.stderr.write(e.msg) failed = True finally: if failed: raise SystemExit(2) total = TotalResult(results) call_hook('after', 'all', total) finished_at = datetime.now() time_took = finished_at - started_at hours = time_took.seconds / 60 / 60 minutes = time_took.seconds / 60 seconds = time_took.seconds if hours: print "(finished within %d hours)" % hours elif minutes: print "(finished within %d minutes)" % minutes elif seconds: print "(finished within %d seconds)" % seconds
except: if not self.failfast: e = sys.exc_info()[1] print "Died with %s" % str(e) traceback.print_exc() else: print print( "Lettuce aborted running any more tests " "because was called with the `--failfast` option") failed = True finally: total_time = datetime.utcnow() - begin_time total = TotalResult(results, total_time) call_hook('after', 'batch') call_hook('after', 'all', total) if failed: raise SystemExit(2) return total class ParallelRunner(Runner): def __init__(self, base_path, scenarios=None, verbosity=0, random=False,