Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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
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)
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
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
def _step_name(step):
assert isinstance(step, Step)
return step.keyword + " " + step.name.strip()
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
>>> 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