How to use the behave.model.Feature 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_feature_hooks_not_run_if_feature_not_being_run(self):
        self.config.tag_expression.check.return_value = False  # pylint: disable=no-member

        feature = Feature("foo.feature", 1, u"Feature", u"foo")
        feature.run(self.runner)
        assert not self.run_hook.called
github behave / behave / tests / unit / test_model.py View on Github external
def test_formatter_feature_called(self):
        feature = Feature("foo.feature", 1, u"Feature", u"foo",
                          background=Mock())

        feature.run(self.runner)

        self.formatters[0].feature.assert_called_with(feature)
github behave / behave / tests / unit / test_model.py View on Github external
def test_formatter_background_not_called_when_feature_has_no_background(self):
        feature = Feature("foo.feature", 1, u"Feature", u"foo")

        feature.run(self.runner)

        assert not self.formatters[0].background.called
github behave / behave / tests / unit / test_formatter.py View on Github external
def _feature(self, keyword=u"k\xe9yword", name=u"name", tags=None,
                 location=u"location", # pylint: disable=unused-argument
                 description=None, scenarios=None, background=None):
        if tags is None:
            tags = [u"spam", u"ham"]
        if description is None:
            description = [u"description"]
        if scenarios is None:
            scenarios = []
        line = self.line
        tags = [Tag(name, line) for name in tags]
        return Feature("", line, keyword, name, tags=tags,
                       description=description, scenarios=scenarios,
                       background=background)
github behave / behave / behave / parser.py View on Github external
def _build_feature(self, keyword, line):
        name = line[len(keyword) + 1:].strip()
        language = self.language or DEFAULT_LANGUAGE
        feature = model.Feature(self.filename, self.line, keyword, name,
                                tags=self.tags, language=language)
        self.feature = feature
        self.scenario_container = feature
        self.rule = None
        # -- RESET STATE:
        self.tags = []
github behave / behave / features / steps / behave_model_util.py View on Github external
def build_feature(self, name=u"", tags=None):
        if not name:
            name = u"alice"
        filename = u"%s.feature" % name
        line = 1
        feature = Feature(filename, line, u"Feature", name, tags=tags)
        self.features.append(feature)
        self.current_feature = feature
        return feature
github behave / behave / behave / runner_util.py View on Github external
def make_line_data_for(cls, entity):
        line_data = []
        run_items = []
        if isinstance(entity, Feature):
            line_data.append((0, entity))
            run_items = entity.run_items
        elif isinstance(entity, Rule):
            run_items = entity.run_items
        elif isinstance(entity, ScenarioOutline):
            run_items = entity.scenarios

        line_data.append((entity.location.line, entity))
        for run_item in run_items:
            line_data.extend(cls.make_line_data_for(run_item))
        # -- MAYBE:
        # if isinstance(entity, ScenarioOutline) and run_items:
        #     # -- SPECIAL CASE: Lines after last Examples row => Use ScenarioOutline
        #     line_data.append((run_items[-1].location.line + 1, entity))
        return sorted(line_data)