當前位置: 首頁>>代碼示例>>Python>>正文


Python model.Step類代碼示例

本文整理匯總了Python中behave.model.Step的典型用法代碼示例。如果您正苦於以下問題:Python Step類的具體用法?Python Step怎麽用?Python Step使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Step類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_run_sets_text_if_present

    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
開發者ID:behave,項目名稱:behave,代碼行數:7,代碼來源:test_model.py

示例2: test_run_reports_undefined_step_via_formatter_when_not_quiet

    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)
開發者ID:Abdoctor,項目名稱:behave,代碼行數:7,代碼來源:test_model.py

示例3: test_run_sets_text_if_present

    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)
開發者ID:Abdoctor,項目名稱:behave,代碼行數:7,代碼來源:test_model.py

示例4: test_run_runs_before_hook_then_match_then_after_hook

    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), {}),
            ])
開發者ID:Abdoctor,項目名稱:behave,代碼行數:31,代碼來源:test_model.py

示例5: test_run_with_no_match_does_not_touch_formatter_when_quiet

    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
開發者ID:Abdoctor,項目名稱:behave,代碼行數:7,代碼來源:test_model.py

示例6: test_run_appends_step_to_undefined_when_no_match_found

    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
        assert step.status == Status.undefined
開發者ID:behave,項目名稱:behave,代碼行數:8,代碼來源:test_model.py

示例7: test_run_appends_step_to_undefined_when_no_match_found

    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)
開發者ID:Abdoctor,項目名稱:behave,代碼行數:8,代碼來源:test_model.py

示例8: test_run_sets_status_to_passed_if_nothing_goes_wrong

    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)
開發者ID:Abdoctor,項目名稱:behave,代碼行數:8,代碼來源:test_model.py

示例9: test_run_sets_status_to_passed_if_nothing_goes_wrong

    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
開發者ID:behave,項目名稱:behave,代碼行數:8,代碼來源:test_model.py

示例10: test_run_captures_stdout_and_logging

    def test_run_captures_stdout_and_logging(self):
        step = Step('foo.feature', 17, u'Given', 'given', u'foo')
        match = Mock()
        self.runner.step_registry.find_match.return_value = match

        assert step.run(self.runner)

        self.runner.start_capture.assert_called_with()
        self.runner.stop_capture.assert_called_with()
開發者ID:Abdoctor,項目名稱:behave,代碼行數:9,代碼來源:test_model.py

示例11: test_run_appends_any_captured_logging_on_failure

    def test_run_appends_any_captured_logging_on_failure(self):
        step = Step("foo.feature", 17, u"Given", "given", u"foo")
        match = Mock()
        self.runner.step_registry.find_match.return_value = match
        self.log_capture.getvalue.return_value = "toads"
        match.run.side_effect = raiser(AssertionError("kipper"))

        assert not step.run(self.runner)
        assert "Captured logging:" in step.error_message
        assert "toads" in step.error_message
開發者ID:behave,項目名稱:behave,代碼行數:10,代碼來源:test_model.py

示例12: test_run_appends_any_captured_stdout_on_failure

    def test_run_appends_any_captured_stdout_on_failure(self):
        step = Step("foo.feature", 17, u"Given", "given", u"foo")
        match = Mock()
        self.runner.step_registry.find_match.return_value = match
        self.stdout_capture.getvalue.return_value = "frogs"
        match.run.side_effect = raiser(Exception("halibut"))

        assert not step.run(self.runner)
        assert "Captured stdout:" in step.error_message
        assert "frogs" in step.error_message
開發者ID:behave,項目名稱:behave,代碼行數:10,代碼來源:test_model.py

示例13: test_run_sets_status_to_failed_on_assertion_error

    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')
開發者ID:007jasonsmith,項目名稱:behave,代碼行數:10,代碼來源:test_model.py

示例14: test_run_sets_status_to_failed_on_exception

    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)
開發者ID:Abdoctor,項目名稱:behave,代碼行數:11,代碼來源:test_model.py

示例15: test_run_sets_status_to_failed_on_exception

    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
開發者ID:behave,項目名稱:behave,代碼行數:11,代碼來源:test_model.py


注:本文中的behave.model.Step類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。