How to use the behave.model_core.Status 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_formatter.py View on Github external
def test_step(self):
        formatters = self._formatters(_tf(), self.config)
        f = self._feature()
        for p in formatters:
            p.feature(f)
            scenario = self._scenario()
            p.scenario(scenario)
            s = self._step()
            p.step(s)
            p.match(self._match([]))
            s.status = Status.passed
            p.result(s)
github behave / behave / tests / unit / test_model.py View on Github external
def test_skipped_steps_set_step_status_and_scenario_status_if_not_set(self):
        self.config.stdout_capture = False
        self.config.log_capture = False
        self.config.tag_expression.check.return_value = False  # pylint: disable=no-member

        steps = [Mock(), Mock()]
        scenario = Scenario("foo.feature", 17, u"Scenario", u"foo",
                            steps=steps)

        scenario.run(self.runner)

        assert False not in [s.status == Status.skipped for s in steps]
        assert scenario.status == Status.skipped
github behave / behave / tests / unit / reporter / test_summary.py View on Github external
def test_scenario_outline_status_is_collected_and_reported(self, stdout,
                                                               format_summary):
        feature = Mock()
        scenarios = [ ScenarioOutline(u"", 0, u"scenario_outline", u"name"),
                      Mock(), Mock(), Mock() ]
        subscenarios = [ Mock(), Mock(), Mock(), Mock() ]
        subscenarios[0].status = Status.passed
        subscenarios[0].__iter__ = Mock(return_value=iter([]))
        subscenarios[1].status = Status.failed
        subscenarios[1].__iter__ = Mock(return_value=iter([]))
        subscenarios[2].status = Status.failed
        subscenarios[2].__iter__ = Mock(return_value=iter([]))
        subscenarios[3].status = Status.skipped
        subscenarios[3].__iter__ = Mock(return_value=iter([]))
        scenarios[0]._scenarios = subscenarios
        scenarios[1].status = Status.failed
        scenarios[1].__iter__ = Mock(return_value=iter([]))
        scenarios[2].status = Status.skipped
        scenarios[2].__iter__ = Mock(return_value=iter([]))
        scenarios[3].status = Status.passed
        scenarios[3].__iter__ = Mock(return_value=iter([]))
        feature.status = Status.failed
        feature.duration = 12.4
        feature.__iter__ = Mock(return_value=iter(scenarios))

        config = Mock()
        sys.stdout.encoding = "UTF-8"
        reporter = SummaryReporter(config)
github behave / behave / tests / unit / reporter / test_summary.py View on Github external
def test_passed_entry_is_pluralised(self):
        summary = {
            Status.passed.name: 10,
            Status.skipped.name: 0,
            Status.failed.name: 0,
            Status.undefined.name: 0,
        }

        assert format_summary('fnord', summary).startswith('10 fnords passed')
github behave / behave / tests / unit / test_model.py View on Github external
steps = [Mock(), Mock()]
        scenario = Scenario("foo.feature", 17, u"Scenario", u"foo",
                            steps=steps)
        steps[0].run.return_value = False
        steps[1].step_type = "when"
        steps[1].name = "step1"

        def step1_function(context):    # pylint: disable=unused-argument
            pass
        my_step_registry = step_registry.StepRegistry()
        my_step_registry.add_step_definition("when", "step1", step1_function)

        with patch("behave.step_registry.registry", my_step_registry):
            assert scenario.run(self.runner)
            assert steps[1].status == Status.skipped
github JetBrains / teamcity-messages / teamcity / jb_behave_formatter.py View on Github external
def result(self, step):
        assert isinstance(step, Step)
        step_name = _step_name(step)
        if step.status == Status.failed:
            try:
                error = traceback.format_exc(step.exc_traceback)
                if error != step.error_message:
                    self._messages.testStdErr(step_name, error)
            except Exception:
                pass  # exception shall not prevent error message
            self._messages.testFailed(step_name, message=step.error_message)

        if step.status == Status.undefined:
            self._messages.testFailed(step_name, message="Undefined")

        if step.status == Status.skipped:
            self._messages.testIgnored(step_name)

        self._messages.testFinished(step_name, testDuration=datetime.datetime.now() - self.__test_start_time)
github behave / behave / behave / reporter / summary.py View on Github external
"""

from __future__ import absolute_import, division, print_function
import sys
from time import time as time_now
from behave.model import Rule, ScenarioOutline  # MAYBE: Scenario
from behave.model_core import Status
from behave.reporter.base import Reporter
from behave.formatter.base import StreamOpener


# ---------------------------------------------------------------------------
# CONSTANTS:
# ---------------------------------------------------------------------------
# -- DISABLED: OPTIONAL_STEPS = ('untested', 'undefined')
OPTIONAL_STEPS = (Status.untested,) # MAYBE: Status.undefined
STATUS_ORDER = (Status.passed, Status.failed, Status.skipped,
                Status.undefined, Status.untested)


# ---------------------------------------------------------------------------
# UTILITY FUNCTIONS:
# ---------------------------------------------------------------------------
def pluralize(word, count=1, suffix="s"):
    if count == 1:
        return word
    # -- OTHERWISE:
    return "{0}{1}".format(word, suffix)


def compute_summary_sum(summary):
    """Compute sum of all summary counts (except: all)
github behave / behave / behave / formatter / pretty.py View on Github external
assert arg.original is not None
            text = step_name[text_start:arg.start]
            self.stream.write(text_format.text(text))
            line_length += len(text)
            self.stream.write(arg_format.text(arg.original))
            line_length += len(arg.original)
            text_start = arg.end

        if text_start != len(step_name):
            text = step_name[text_start:]
            self.stream.write(text_format.text(text))
            line_length += (len(text))

        if self.show_source:
            location = six.text_type(location)
            if self.show_timings and status in (Status.passed, Status.failed):
                location += " %0.3fs" % step.duration
            location = self.indented_text(location, proceed)
            self.stream.write(self.format("comments").text(location))
            line_length += len(location)
        elif self.show_timings and status in (Status.passed, Status.failed):
            timing = "%0.3fs" % step.duration
            timing = self.indented_text(timing, proceed)
            self.stream.write(self.format("comments").text(timing))
            line_length += len(timing)
        self.stream.write("\n")

        self.step_lines = int((line_length - 1) / self.display_width)

        if self.show_multiline:
            if step.text:
                self.doc_string(step.text)
github behave / behave / behave / reporter / base.py View on Github external
def feature(self, feature):
        """
        Called after a feature was processed.

        :param feature:  Feature object (as :class:`behave.model.Feature`)
        """
        assert feature.status != Status.undefined
        raise NotImplementedError
github behave / behave / behave / formatter / rerun.py View on Github external
def eof(self):
        """Called at end of a feature."""
        if self.current_feature and self.current_feature.status == Status.failed:
            # -- COLLECT SCENARIO FAILURES:
            for scenario in self.current_feature.walk_scenarios():
                if scenario.status == Status.failed:
                    self.failed_scenarios.append(scenario)

        # -- RESET:
        self.current_feature = None
        assert self.current_feature is None