Example #1
0
File: rerun.py Project: xbx/behave
    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")
Example #2
0
    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)
Example #3
0
 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
Example #4
0
 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
Example #5
0
    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)
Example #6
0
    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)
Example #7
0
    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)
Example #8
0
 def feature(self, feature):
     self.current_feature = feature
     short_filename = relpath(feature.filename, os.getcwd())
     self.stream.write("%s  " % short_filename)
     self.stream.flush()
Example #9
0
 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))
Example #10
0
 def location(self):
     p = relpath(self.filename, os.getcwd())
     return '%s:%d' % (p, self.line)
Example #11
0
 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
Example #12
0
 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
Example #13
0
 def feature(self, feature):
     self.current_feature = feature
     short_filename = relpath(feature.filename, os.getcwd())
     self.stream.write("%s  " % short_filename)