• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python expects.expect函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中expects.expect函数的典型用法代码示例。如果您正苦于以下问题:Python expect函数的具体用法?Python expect怎么用?Python expect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了expect函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_should_fail_if_inputs_do_not_have_the_same_type

 def test_should_fail_if_inputs_do_not_have_the_same_type(self):
     testf = lambda: timestamp.compare(self.TESTS[0][0],
                                       datetime.datetime.utcnow())
     expect(testf).to(raise_error(ValueError))
     testf = lambda: timestamp.compare(self.TESTS[0],
                                       datetime.datetime.utcnow())
     expect(testf).to(raise_error(ValueError))
开发者ID:AndreaBuffa,项目名称:trenordsaga,代码行数:7,代码来源:test_timestamp.py


示例2: test_when_default_is_callable_then_use_its_returned_value_as_field_default

    def test_when_default_is_callable_then_use_its_returned_value_as_field_default(self):
        default = 'anonymous'
        User.name.default = lambda: default

        user = User()

        expect(user.name).to.be(default)
开发者ID:myaser,项目名称:booby,代码行数:7,代码来源:test_fields.py


示例3: test_should_merge_bucket_counts_correctly

 def test_should_merge_bucket_counts_correctly(self):
     for d1, d2, _ in self.merge_triples:
         d1_start = list(d1.bucketCounts)
         d2_start = list(d2.bucketCounts)
         want = [x + y for (x,y) in zip(d1_start, d2_start)]
         distribution.merge(d1, d2)
         expect(d2.bucketCounts).to(equal(want))
开发者ID:catapult-project,项目名称:catapult,代码行数:7,代码来源:test_distribution.py


示例4: it_should_pass_if_actual_raises_and_message_matches_pattern

    def it_should_pass_if_actual_raises_and_message_matches_pattern():
        pattern = r'\w+ error'

        def callback():
            raise AttributeError(_.message)

        expect(callback).to.raise_error(AttributeError, pattern)
开发者ID:aleasoluciones,项目名称:expects,代码行数:7,代码来源:raise_error_spec.py


示例5: test_flush_pipes_data_between_streams

 def test_flush_pipes_data_between_streams(self):
     a = StringIO(u'food')
     b = StringIO()
     pump = io.Pump(a, b)
     pump.flush(3)
     expect(a.read(1)).to.equal('d')
     expect(b.getvalue()).to.equal('foo')
开发者ID:jaimegildesagredo,项目名称:dockerpty,代码行数:7,代码来源:test_io.py


示例6: test_valid_json_object_as_file

    def test_valid_json_object_as_file(self):
        _file = StringIO()
        _file.write(self.user_meta.to_json())
        _file.seek(0)

        actual = serialize.deserialize(_file)
        expect(actual).to.equal([self.user_meta])
开发者ID:myaser,项目名称:booby,代码行数:7,代码来源:test_serialize.py


示例7: test_should_send_requests_with_default_query_param_api_key

 def test_should_send_requests_with_default_query_param_api_key(self):
     for default_key in (u'key', u'api_key'):
         wrappee = _DummyWsgiApp()
         control_client = mock.MagicMock(spec=client.Client)
         given = {
             u'wsgi.url_scheme': u'http',
             u'QUERY_STRING': u'%s=my-default-api-key-value' % (default_key,),
             u'PATH_INFO': u'/uvw/method_needs_api_key/with_query_param',
             u'REMOTE_ADDR': u'192.168.0.3',
             u'HTTP_HOST': u'localhost',
             u'HTTP_REFERER': u'example.myreferer.com',
             u'REQUEST_METHOD': u'GET'}
         dummy_response = sc_messages.CheckResponse(
             operationId=u'fake_operation_id')
         wrapped = wsgi.add_all(wrappee,
                                self.PROJECT_ID,
                                control_client,
                                loader=service.Loaders.ENVIRONMENT)
         control_client.check.return_value = dummy_response
         wrapped(given, _dummy_start_response)
         expect(control_client.check.called).to(be_true)
         check_request = control_client.check.call_args_list[0].checkRequest
         check_req = control_client.check.call_args[0][0]
         expect(check_req.checkRequest.operation.consumerId).to(
             equal(u'api_key:my-default-api-key-value'))
         expect(control_client.report.called).to(be_true)
         report_req = control_client.report.call_args[0][0]
         expect(report_req.reportRequest.operations[0].consumerId).to(
             equal(u'api_key:my-default-api-key-value'))
         expect(control_client.allocate_quota.called).to(be_false)
开发者ID:AndreaBuffa,项目名称:trenordsaga,代码行数:30,代码来源:test_wsgi.py


示例8: test_should_not_send_the_request_if_cached

 def test_should_not_send_the_request_if_cached(self, dummy_thread_class):
     t = self._mock_transport
     self._subject.start()
     dummy_request = _make_dummy_report_request(self.PROJECT_ID,
                                                self.SERVICE_NAME)
     self._subject.report(dummy_request)
     expect(t.services.report.called).to(be_false)
开发者ID:danacton,项目名称:appengine-endpoints-modules-lnkr,代码行数:7,代码来源:test_client.py


示例9: assert_messages_and_user

def assert_messages_and_user(context, numero, usuario):
    count = int(numero)
    #context.thread['msgs'].should.have.length_of(count)
    expect(context.thread['msgs']).to.have.length(count)
    msg = context.thread['msgs'][0]
    #msg['user'].should.equal(usuario)
    expect(msg['user']).to.equal(usuario)
开发者ID:javierj,项目名称:LaPISK,代码行数:7,代码来源:informedemenciones.py


示例10: test_should_clear_requests_on_stop

 def test_should_clear_requests_on_stop(self, dummy_thread_class):
     # stop the subject, the transport did not see a request
     self._subject.start()
     self._subject.report(
         _make_dummy_report_request(self.PROJECT_ID, self.SERVICE_NAME))
     self._subject.stop()
     expect(self._mock_transport.services.report.called).to(be_true)
开发者ID:danacton,项目名称:appengine-endpoints-modules-lnkr,代码行数:7,代码来源:test_client.py


示例11: test_should_ignore_bad_transport_when_not_cached

 def test_should_ignore_bad_transport_when_not_cached(self, dummy_thread_class):
     self._subject.start()
     self._subject.report(
         _make_dummy_report_request(self.PROJECT_ID, self.SERVICE_NAME))
     self._mock_transport.services.report.side_effect = lambda: old_div(1,0)
     self._subject.stop()
     expect(self._mock_transport.services.report.called).to(be_true)
开发者ID:danacton,项目名称:appengine-endpoints-modules-lnkr,代码行数:7,代码来源:test_client.py


示例12: test_when_model_validate_raises_validation_error_then_raises_validation_error

    def test_when_model_validate_raises_validation_error_then_raises_validation_error(self):
        class InvalidUser(User):
            def validate(self):
                raise errors.ValidationError()

        expect(lambda: self.validator(InvalidUser())).to.raise_error(
            errors.ValidationError)
开发者ID:myaser,项目名称:booby,代码行数:7,代码来源:test_validators.py


示例13: should_copy_the_songs_to_the_destination_directory

        def should_copy_the_songs_to_the_destination_directory():
            execution = _.env.run(*_.cmd + ['--dest', 'pulled', 'pull'])

            copied_songs = [path for path in execution.files_created
                            if 'pulled' in path and path.endswith('.mp3')]

            expect(copied_songs).to.have.length(2)
开发者ID:jvrsantacruz,项目名称:ipodio,代码行数:7,代码来源:pull_spec.py


示例14: test_should_convert_correctly_with_nanos

 def test_should_convert_correctly_with_nanos(self):
     for t in self.NANO_TESTS:
         dt, nanos = timestamp.from_rfc3339(t[0], with_nanos=True)
         expect(dt).to(equal(t[1][0]))
         epsilon = abs(nanos - t[1][1])
         # expect(epsilon).to(equal(0))
         expect(epsilon).to(be_below_or_equal(self.TOLERANCE))
开发者ID:AndreaBuffa,项目名称:trenordsaga,代码行数:7,代码来源:test_timestamp.py


示例15: test_should_return_none_initially_as_req_is_not_cached

 def test_should_return_none_initially_as_req_is_not_cached(self):
     req = _make_test_request(self.SERVICE_NAME, self.FAKE_OPERATION_ID)
     fake_response = sc_messages.AllocateQuotaResponse(
         operationId=self.FAKE_OPERATION_ID)
     agg = self.agg
     actual = agg.allocate_quota(req)
     expect(actual).to(equal(fake_response))
开发者ID:AndreaBuffa,项目名称:trenordsaga,代码行数:7,代码来源:test_quota_request.py


示例16: should_call_only_with_arguments_that_the_handler_understands

        def should_call_only_with_arguments_that_the_handler_understands():
            call_args = {"evil_extra": None}
            call_args.update(_.handler_kwargs)

            call_result = _.command.call(**call_args)

            expect(call_result).to.be.equal(_.called)
开发者ID:jvrsantacruz,项目名称:ipodio,代码行数:7,代码来源:command_spec.py


示例17: test_request_extraction_with_aggregation

    def test_request_extraction_with_aggregation(self):
        req = _make_test_request(self.SERVICE_NAME, self.FAKE_OPERATION_ID)
        req = req.allocateQuotaRequest
        req.allocateOperation.quotaMetrics = [
            sc_messages.MetricValueSet(
                metricName=u'a_float',
                metricValues=[
                    metric_value.create(
                        labels={
                            u'key1': u'value1',
                            u'key2': u'value2'},
                        int64Value=12,
                    ),
                ]
            )
        ]

        resp = sc_messages.AllocateQuotaResponse(
            operationId=self.FAKE_OPERATION_ID)
        item = quota_request.CachedItem(req, resp, self.SERVICE_NAME, None)
        expect(item._op_aggregator).to(be_none)
        item.aggregate(req)
        item.aggregate(req)

        extracted = item.extract_request()
        op = extracted.allocateQuotaRequest.allocateOperation
        expect(op.quotaMetrics[0].metricValues[0].int64Value).to(equal(24))
开发者ID:AndreaBuffa,项目名称:trenordsaga,代码行数:27,代码来源:test_quota_request.py


示例18: test_should_add_matching_hashes_for_matching_labels

 def test_should_add_matching_hashes_for_matching_labels(self):
     a_dict = {'test': 'dict'}
     mv1 = metric_value.create(labels=a_dict)
     mv2 = metric_value.create(labels=a_dict)
     want = self.make_hash(mv1)
     got = self.make_hash(mv2)
     expect(got).to(equal(want))
开发者ID:catapult-project,项目名称:catapult,代码行数:7,代码来源:test_metric_value.py


示例19: it_should_return_the_correct_list_of_available_paths_equal_to_4_size

 def it_should_return_the_correct_list_of_available_paths_equal_to_4_size(self):
     expected_paths = [
         [self.vertexA, self.vertexB, self.vertexC, self.vertexD]
     ]
     expect(self.paths_equal_4_size).to(have_len(1))
     for path in expected_paths:
         expect(self.paths_equal_4_size).to(contain(path))
开发者ID:ekiourk,项目名称:hermes,代码行数:7,代码来源:test_find_all_paths.py


示例20: test_should_fail_if_actual_has_header_without_value_in_kwargs

    def test_should_fail_if_actual_has_header_without_value_in_kwargs(self):
        with failure(self.response,
                     "to have header 'content-length' with value '25'"):

            expect(response=self.response).to.have.headers(
                content_type=IRRELEVANT_HEADER_VALUE1,
                content_length='25')
开发者ID:izamarro,项目名称:requests-expects,代码行数:7,代码来源:test_headers.py



注:本文中的expects.expect函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python expects.raise_error函数代码示例发布时间:2022-05-24
下一篇:
Python expects.equal函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap