本文整理汇总了Python中behave.model.Step.run方法的典型用法代码示例。如果您正苦于以下问题:Python Step.run方法的具体用法?Python Step.run怎么用?Python Step.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类behave.model.Step
的用法示例。
在下文中一共展示了Step.run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_run_runs_before_hook_then_match_then_after_hook
# 需要导入模块: from behave.model import Step [as 别名]
# 或者: from behave.model.Step import run [as 别名]
def test_run_runs_before_hook_then_match_then_after_hook(self):
step = Step('foo.feature', 17, u'Given', 'given', u'foo')
match = Mock()
self.runner.step_registry.find_match.return_value = match
side_effects = (None, AssertionError('whee'), Exception('whee'))
for side_effect in side_effects:
# Make match.run() and runner.run_hook() the same mock so
# we can make sure things happen in the right order.
self.runner.run_hook = match.run = Mock()
def effect(thing):
# pylint: disable=unused-argument
def raiser_(*args, **kwargs):
match.run.side_effect = None
if thing:
raise thing
def nonraiser(*args, **kwargs):
match.run.side_effect = raiser_
return nonraiser
match.run.side_effect = effect(side_effect)
step.run(self.runner)
eq_(match.run.call_args_list, [
(('before_step', self.context, step), {}),
((self.context,), {}),
(('after_step', self.context, step), {}),
])
示例2: test_run_sets_text_if_present
# 需要导入模块: from behave.model import Step [as 别名]
# 或者: from behave.model.Step import run [as 别名]
def test_run_sets_text_if_present(self):
step = Step('foo.feature', 17, u'Given', 'given', u'foo',
text=Mock(name='text'))
self.runner.step_registry.find_match.return_value = Mock()
step.run(self.runner)
eq_(self.context.text, step.text)
示例3: test_run_sets_text_if_present
# 需要导入模块: from behave.model import Step [as 别名]
# 或者: from behave.model.Step import run [as 别名]
def test_run_sets_text_if_present(self):
step = Step("foo.feature", 17, u"Given", "given", u"foo",
text=Mock(name="text"))
self.runner.step_registry.find_match.return_value = Mock()
step.run(self.runner)
assert self.context.text == step.text
示例4: test_run_sets_status_to_passed_if_nothing_goes_wrong
# 需要导入模块: from behave.model import Step [as 别名]
# 或者: from behave.model.Step import run [as 别名]
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)
eq_(step.status, Status.passed)
eq_(step.error_message, None)
示例5: test_run_sets_status_to_passed_if_nothing_goes_wrong
# 需要导入模块: from behave.model import Step [as 别名]
# 或者: from behave.model.Step import run [as 别名]
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
示例6: test_run_sets_status_to_failed_on_assertion_error
# 需要导入模块: from behave.model import Step [as 别名]
# 或者: from behave.model.Step import run [as 别名]
def test_run_sets_status_to_failed_on_assertion_error(self):
step = Step('foo.feature', 17, u'Given', 'given', u'foo')
step.error_message = None
match = Mock()
match.run.side_effect = raiser(AssertionError('whee'))
self.runner.step_registry.find_match.return_value = match
step.run(self.runner)
eq_(step.status, 'failed')
assert step.error_message.startswith('Assertion Failed')
示例7: test_run_sets_status_to_failed_on_exception
# 需要导入模块: from behave.model import Step [as 别名]
# 或者: from behave.model.Step import run [as 别名]
def test_run_sets_status_to_failed_on_exception(self, format_exc):
step = Step('foo.feature', 17, u'Given', 'given', u'foo')
step.error_message = None
match = Mock()
match.run.side_effect = raiser(Exception('whee'))
self.runner.step_registry.find_match.return_value = match
format_exc.return_value = 'something to do with an exception'
step.run(self.runner)
eq_(step.status, Status.failed)
eq_(step.error_message, format_exc.return_value)
示例8: test_run_sets_status_to_failed_on_exception
# 需要导入模块: from behave.model import Step [as 别名]
# 或者: from behave.model.Step import run [as 别名]
def test_run_sets_status_to_failed_on_exception(self, format_exc):
step = Step("foo.feature", 17, u"Given", "given", u"foo")
step.error_message = None
match = Mock()
match.run.side_effect = raiser(Exception("whee"))
self.runner.step_registry.find_match.return_value = match
format_exc.return_value = "something to do with an exception"
step.run(self.runner)
assert step.status == Status.failed
assert step.error_message == format_exc.return_value
示例9: test_run_when_not_quiet_reports_match_and_result
# 需要导入模块: from behave.model import Step [as 别名]
# 或者: from behave.model.Step import run [as 别名]
def test_run_when_not_quiet_reports_match_and_result(self):
step = Step('foo.feature', 17, u'Given', 'given', u'foo')
match = Mock()
self.runner.step_registry.find_match.return_value = match
side_effects = (None, raiser(AssertionError('whee')),
raiser(Exception('whee')))
for side_effect in side_effects:
match.run.side_effect = side_effect
step.run(self.runner)
self.formatters[0].match.assert_called_with(match)
self.formatters[0].result.assert_called_with(step)
示例10: test_run_when_quiet_reports_nothing
# 需要导入模块: from behave.model import Step [as 别名]
# 或者: from behave.model.Step import run [as 别名]
def test_run_when_quiet_reports_nothing(self):
step = Step('foo.feature', 17, u'Given', 'given', u'foo')
match = Mock()
self.runner.step_registry.find_match.return_value = match
side_effects = (None, raiser(AssertionError('whee')),
raiser(Exception('whee')))
for side_effect in side_effects:
match.run.side_effect = side_effect
step.run(self.runner, quiet=True)
assert not self.formatters[0].match.called
assert not self.formatters[0].result.called
示例11: test_run_sets_status_to_failed_on_assertion_error
# 需要导入模块: from behave.model import Step [as 别名]
# 或者: from behave.model.Step import run [as 别名]
def test_run_sets_status_to_failed_on_assertion_error(self):
step = Step('foo.feature', 17, u'Given', 'given', u'foo')
self.runner.context = Context(self.runner)
self.runner.config.stdout_capture = True
self.runner.config.log_capture = False
self.runner.capture_controller = CaptureController(self.runner.config)
self.runner.capture_controller.setup_capture(self.runner.context)
step.error_message = None
match = Mock()
match.run.side_effect = raiser(AssertionError('whee'))
self.runner.step_registry.find_match.return_value = match
step.run(self.runner)
eq_(step.status, Status.failed)
assert step.error_message.startswith('Assertion Failed')
示例12: test_run_sets_status_to_failed_on_assertion_error
# 需要导入模块: from behave.model import Step [as 别名]
# 或者: from behave.model.Step import run [as 别名]
def test_run_sets_status_to_failed_on_assertion_error(self):
step = Step("foo.feature", 17, u"Given", "given", u"foo")
self.runner.context = Context(self.runner)
self.runner.config.stdout_capture = True
self.runner.config.log_capture = False
self.runner.capture_controller = CaptureController(self.runner.config)
self.runner.capture_controller.setup_capture(self.runner.context)
step.error_message = None
match = Mock()
match.run.side_effect = raiser(AssertionError("whee"))
self.runner.step_registry.find_match.return_value = match
step.run(self.runner)
assert step.status == Status.failed
assert step.error_message.startswith("Assertion Failed")
示例13: test_run_reports_undefined_step_via_formatter_when_not_quiet
# 需要导入模块: from behave.model import Step [as 别名]
# 或者: from behave.model.Step import run [as 别名]
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)
示例14: test_run_with_no_match_does_not_touch_formatter_when_quiet
# 需要导入模块: from behave.model import Step [as 别名]
# 或者: from behave.model.Step import run [as 别名]
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
示例15: test_run_appends_step_to_undefined_when_no_match_found
# 需要导入模块: from behave.model import Step [as 别名]
# 或者: from behave.model.Step import run [as 别名]
def test_run_appends_step_to_undefined_when_no_match_found(self):
step = Step('foo.feature', 17, u'Given', 'given', u'foo')
self.runner.step_registry.find_match.return_value = None
self.runner.undefined_steps = []
assert not step.run(self.runner)
assert step in self.runner.undefined_steps
eq_(step.status, Status.undefined)