def report_scenario_failures(self): assert self.failed_scenarios # -- SECTION: Banner message = u"# -- RERUN: %d failing scenarios during last test run.\n" self.stream.write(message % len(self.failed_scenarios)) if self.show_timestamp: now = datetime.now().replace(microsecond=0) self.stream.write("# NOW: %s\n"% now.isoformat(" ")) # -- SECTION: Textual summary in comments. if self.show_failed_scenarios_descriptions: current_feature = None for index, scenario in enumerate(self.failed_scenarios): if current_feature != scenario.filename: if current_feature is not None: self.stream.write(u"#\n") current_feature = scenario.filename short_filename = relpath(scenario.filename, os.getcwd()) self.stream.write(u"# %s\n" % short_filename) self.stream.write(u"# %4d: %s\n" % \ (scenario.line, scenario.name)) self.stream.write("\n") # -- SECTION: Scenario file locations, ala: "alice.feature:10" for scenario in self.failed_scenarios: self.stream.write(u"%s\n" % scenario.location) self.stream.write("\n")
def relpath(self, start=os.curdir): """ Compute relative path for start to filename. :param start: Base path or start directory (default=current dir). :return: Relative path from start to filename """ return relpath(self.filename, start)
def __init__(self, filename, line, keyword, name): filename = filename or '<string>' filename = relpath(filename, os.getcwd()) # -- NEEDS: abspath? self.location = FileLocation(filename, line) assert isinstance(keyword, unicode) assert isinstance(name, unicode) self.keyword = keyword self.name = name
def make_location(step_function): ''' Extracts the location information from the step function and builds the location string (schema: "{source_filename}:{line_number}"). :param step_function: Function whose location should be determined. :return: Step function location as string. ''' filename = relpath(step_function.func_code.co_filename, os.getcwd()) line_number = step_function.func_code.co_firstlineno return FileLocation(filename, line_number)
def feature(self, feature): self.current_feature = feature short_filename = relpath(feature.filename, os.getcwd()) self.stream.write("%s " % short_filename) self.stream.flush()
def feature(self, feature): self.current_feature = feature short_filename = relpath(feature.filename, os.getcwd()) self.stream.write(u"%s # %s" % (feature.name, short_filename))
def location(self): p = relpath(self.filename, os.getcwd()) return '%s:%d' % (p, self.line)
def filename(self): if not self._filename: if self.step_definitions: filename = inspect.getfile(self.step_definitions[0].func) self._filename = relpath(filename) return self._filename
def feature(self, feature): self.current_feature = feature short_filename = relpath(feature.filename, os.getcwd()) self.stream.write("%s " % short_filename)