How to use the behave.model.Step function in behave

To help you get started, we’ve selected a few behave examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github behave / behave / tests / unit / test_model.py View on Github external
def test_run_reports_undefined_step_via_formatter_when_not_quiet(self):
        step = Step("foo.feature", 17, u"Given", "given", u"foo")
        self.runner.step_registry.find_match.return_value = None
        assert not step.run(self.runner)

        self.formatters[0].match.assert_called_with(NoMatch())
        self.formatters[0].result.assert_called_with(step)
github behave / behave / tests / unit / test_model.py View on Github external
def test_run_sets_status_to_passed_if_nothing_goes_wrong(self):
        step = Step("foo.feature", 17, u"Given", "given", u"foo")
        step.error_message = None
        self.runner.step_registry.find_match.return_value = Mock()
        step.run(self.runner)

        assert step.status == Status.passed
        assert step.error_message is None
github behave / behave / tests / unit / test_formatter.py View on Github external
def _step(self, keyword=u"k\xe9yword", step_type="given", name=u"name",
              text=None, table=None):
        line = self.line
        return Step("", line, keyword, step_type, name, text=text,
                    table=table)
github behave / behave / tests / unit / test_model.py View on Github external
def test_run_with_no_match_does_not_touch_formatter_when_quiet(self):
        step = Step("foo.feature", 17, u"Given", "given", u"foo")
        self.runner.step_registry.find_match.return_value = None
        assert not step.run(self.runner, quiet=True)

        assert not self.formatters[0].match.called
        assert not self.formatters[0].result.called
github behave / behave / behave / json_parser.py View on Github external
element = self.current_feature_element
        element['steps'].append(s)
        """
        keyword = json_element.get("keyword", u"")
        name    = json_element.get("name", u"")
        step_type = json_element.get("step_type", u"")
        location = json_element.get("location", u"")
        text = json_element.get("text", None)
        if isinstance(text, list):
            text = "\n".join(text)
        table = None
        json_table = json_element.get("table", None)
        if json_table:
            table = self.parse_table(json_table)
        filename, line = location.split(":")
        step = model.Step(filename, line, keyword, step_type, name)
        step.text = text
        step.table = table
        json_result = json_element.get("result", None)
        if json_result:
            self.add_step_result(step, json_result)
        return step
github JetBrains / teamcity-messages / teamcity / jb_behave_formatter.py View on Github external
def _step_name(step):
    assert isinstance(step, Step)
    return step.keyword + " " + step.name.strip()
github behave / behave / behave / model.py View on Github external
def reset(self):
        """Reset temporary runtime data to reach clean state again."""
        super(Step, self).reset()
        self.status = Status.untested
        self.hook_failed = False
        self.duration = 0
        # -- POSTCONDITION: assert self.status == Status.untested
github behave / behave / behave / reporter / junit.py View on Github external
>>> failed_step = select_step_with_status(Status.failed, scenario.all_steps)
            >>> assert failed_step.status == Status.failed

        EXAMPLE: Search only scenario steps, skip background steps.
            >>> failed_step = select_step_with_status(Status.failed, scenario.steps)

        :param status:  Step status to search for (as enum value).
        :param steps:   List of steps to search in (or scenario).
        :returns: Step object, if found.
        :returns: None, otherwise.

        .. versionchanged:: 1.2.6
            status: Use enum value instead of string (or string).
        """
        for step in steps:
            assert isinstance(step, Step), \
                "TYPE-MISMATCH: step.class=%s"  % step.__class__.__name__
            if step.status == status:
                return step
        # -- OTHERWISE: No step with the given status found.
        # KeyError("Step with status={0} not found".format(status))
        return None
    # pylint: enable=line-too-long