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

Python expects.equal函数代码示例

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

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



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

示例1: test_should_return_ttl_cache_if_flush_interval_is_positive

    def test_should_return_ttl_cache_if_flush_interval_is_positive(self):
        delta = datetime.timedelta(seconds=1)
        should_be_ttl = [
            lambda timer: caches.create(
                caches.CheckOptions(num_entries=1, flush_interval=delta),
                timer=timer
            ),
            lambda timer: caches.create(
                caches.ReportOptions(num_entries=1, flush_interval=delta),
                timer=timer
            ),
        ]
        for testf in should_be_ttl:
            timer = _DateTimeTimer()
            sync_cache = testf(timer)
            expect(sync_cache).to(be_a(caches.LockedObject))
            with sync_cache as cache:
                expect(cache).to(be_a(caches.DequeOutTTLCache))
                expect(cache.timer()).to(equal(0))
                cache[1] = 1
                expect(set(cache)).to(equal({1}))
                expect(cache.get(1)).to(equal(1))
                timer.tick()
                expect(cache.get(1)).to(equal(1))
                timer.tick()
                expect(cache.get(1)).to(be_none)

            # Is still TTL without the custom timer
            sync_cache = testf(None)
            expect(sync_cache).to(be_a(caches.LockedObject))
            with sync_cache as cache:
                expect(cache).to(be_a(caches.DequeOutTTLCache))
开发者ID:AndreaBuffa,项目名称:trenordsaga,代码行数:32,代码来源:test_caches.py


示例2: 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:bschmeck,项目名称:dockerpty,代码行数:7,代码来源:test_io.py


示例3: test_should_update_temp_response_with_actual

 def test_should_update_temp_response_with_actual(self):
     req = _make_test_request(self.SERVICE_NAME, self.FAKE_OPERATION_ID)
     temp_response = sc_messages.AllocateQuotaResponse(
         operationId=self.FAKE_OPERATION_ID)
     real_response = sc_messages.AllocateQuotaResponse(
         operationId=self.FAKE_OPERATION_ID,
         quotaMetrics=[sc_messages.MetricValueSet(
             metricName=u'a_float',
             metricValues=[
                 metric_value.create(
                     labels={
                         u'key1': u'value1',
                         u'key2': u'value2'},
                     doubleValue=1.1,
                 ),
             ]
         )]
     )
     agg = self.agg
     agg.allocate_quota(req)
     signature = quota_request.sign(req.allocateQuotaRequest)
     with agg._cache as cache:
         item = cache[signature]
         expect(item.response).to(equal(temp_response))
         expect(item.is_in_flight).to(be_true)
         agg.add_response(req, real_response)
         item = cache[signature]
         expect(item.response).to(equal(real_response))
         expect(item.is_in_flight).to(be_false)
开发者ID:AndreaBuffa,项目名称:trenordsaga,代码行数:29,代码来源:test_quota_request.py


示例4: 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


示例5: _expect_stats_eq_direct_calc_from_samples

def _expect_stats_eq_direct_calc_from_samples(d, samples):
    # pylint: disable=fixme
    # TODO: update this the sum of rho-squared
    want_mean = sum(samples) / len(samples)
    expect(d.mean).to(equal(want_mean))
    expect(d.maximum).to(equal(max(samples)))
    expect(d.minimum).to(equal(min(samples)))
开发者ID:catapult-project,项目名称:catapult,代码行数:7,代码来源:test_distribution.py


示例6: test_should_not_enter_scheduler_for_cached_checks

    def test_should_not_enter_scheduler_for_cached_checks(self, sched, thread_class):
        thread_class.return_value.start.side_effect = lambda: old_div(1,0)
        self._subject.start()

        # confirm scheduler is created and initialized
        expect(sched.scheduler.called).to(be_true)
        scheduler = sched.scheduler.return_value
        expect(scheduler.enter.called).to(be_true)
        scheduler.reset_mock()

        # call check once, to a cache response
        dummy_request = _make_dummy_check_request(self.PROJECT_ID,
                                                  self.SERVICE_NAME)
        dummy_response = messages.CheckResponse(
            operationId=dummy_request.checkRequest.operation.operationId)
        t = self._mock_transport
        t.services.check.return_value = dummy_response
        expect(self._subject.check(dummy_request)).to(equal(dummy_response))
        t.reset_mock()

        # call check again - response is cached...
        expect(self._subject.check(dummy_request)).to(equal(dummy_response))
        expect(self._mock_transport.services.check.called).to(be_false)

        # ... the scheduler is not run
        expect(scheduler.run.called).to(be_false)
开发者ID:danacton,项目名称:appengine-endpoints-modules-lnkr,代码行数:26,代码来源:test_client.py


示例7: test_should_send_requests_with_configured_header_api_key

 def test_should_send_requests_with_configured_header_api_key(self):
     wrappee = _DummyWsgiApp()
     control_client = mock.MagicMock(spec=client.Client)
     given = {
         u'wsgi.url_scheme': u'http',
         u'PATH_INFO': u'/uvw/method1/with_query_param',
         u'REMOTE_ADDR': u'192.168.0.3',
         u'HTTP_HOST': u'localhost',
         u'HTTP_APIKEYHEADER': u'my-header-value',
         u'HTTP_REFERER': u'example.myreferer.com',
         u'REQUEST_METHOD': u'GET'}
     dummy_response = 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-header-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-header-value'))
开发者ID:danacton,项目名称:appengine-endpoints-modules-lnkr,代码行数:27,代码来源:test_wsgi.py


示例8: test_signals_resend_on_1st_call_after_flush_interval_with_errors

    def test_signals_resend_on_1st_call_after_flush_interval_with_errors(self):
        req = _make_test_request(self.SERVICE_NAME)
        failure_code = messages.CheckError.CodeValueValuesEnum.NOT_FOUND
        fake_response = messages.CheckResponse(
            operationId=self.FAKE_OPERATION_ID, checkErrors=[
                messages.CheckError(code=failure_code)
            ])
        agg = self.agg
        expect(agg.check(req)).to(be_none)
        agg.add_response(req, fake_response)
        expect(agg.check(req)).to(equal(fake_response))

        # Now flush interval is reached, but not the response expiry
        self.timer.tick() # now past the flush_interval
        expect(agg.check(req)).to(be_none)  # first response is null

        # until expiry, the response will continue to be returned
        expect(agg.check(req)).to(equal(fake_response))
        expect(agg.check(req)).to(equal(fake_response))

        # expire
        self.timer.tick()
        self.timer.tick() # now expired
        expect(agg.check(req)).to(be_none)
        expect(agg.check(req)).to(be_none) # 2nd check is None as well
开发者ID:danacton,项目名称:appengine-endpoints-modules-lnkr,代码行数:25,代码来源:test_check_request.py


示例9: test_should_create_with_defaults

 def test_should_create_with_defaults(self):
     options = caches.CheckOptions()
     expect(options.num_entries).to(equal(
         caches.CheckOptions.DEFAULT_NUM_ENTRIES))
     expect(options.flush_interval).to(equal(
         caches.CheckOptions.DEFAULT_FLUSH_INTERVAL))
     expect(options.expiration).to(equal(
         caches.CheckOptions.DEFAULT_EXPIRATION))
开发者ID:AndreaBuffa,项目名称:trenordsaga,代码行数:8,代码来源:test_caches.py


示例10: test_should_ignores_lower_expiration

 def test_should_ignores_lower_expiration(self):
     wanted_expiration = (
         self.AN_INTERVAL + datetime.timedelta(milliseconds=1))
     options = caches.CheckOptions(flush_interval=self.AN_INTERVAL,
                                   expiration=self.A_LOWER_INTERVAL)
     expect(options.flush_interval).to(equal(self.AN_INTERVAL))
     expect(options.expiration).to(equal(wanted_expiration))
     expect(options.expiration).not_to(equal(self.A_LOWER_INTERVAL))
开发者ID:AndreaBuffa,项目名称:trenordsaga,代码行数:8,代码来源:test_caches.py


示例11: test_should_construct_with_ok_expected_args

 def test_should_construct_with_ok_expected_args(self):
     rules = self.subject_cls(logs=[u'wanted_log'],
                              metrics=self.WANTED_METRICS,
                              labels=self.WANTED_LABELS)
     expect(rules).not_to(be_none)
     expect(rules.logs).to(equal(set([u'wanted_log'])))
     expect(rules.metrics).to(equal(self.WANTED_METRICS))
     expect(rules.labels).to(equal(self.WANTED_LABELS))
开发者ID:danacton,项目名称:appengine-endpoints-modules-lnkr,代码行数:8,代码来源:test_report_request.py


示例12: test_should_merge_stats_correctly

 def test_should_merge_stats_correctly(self):
     # TODO(add a check of the variance)
     for d1, d2, _ in self.merge_triples:
         distribution.merge(d1, d2)
         expect(d2.count).to(equal(2))
         expect(d2.mean).to(equal((_HIGH_SAMPLE + _LOW_SAMPLE) / 2))
         expect(d2.maximum).to(equal(_HIGH_SAMPLE))
         expect(d2.minimum).to(equal(_LOW_SAMPLE))
开发者ID:catapult-project,项目名称:catapult,代码行数:8,代码来源:test_distribution.py


示例13: it_should_insert_a_short_url

    def it_should_insert_a_short_url(self):
        uow = inject.instance('UnitOfWorkManager')
        with uow.start() as tx:
            s_url = tx.short_urls.get(self.given_sid)

        expect(s_url).to(be_a(ShortUrl))
        expect(s_url.url).to(equal(self.url))
        expect(s_url.user).to(equal(user))
开发者ID:ekiourk,项目名称:yatu,代码行数:8,代码来源:test_url_creation.py


示例14: it_should_handle_the_collison_and_insert_the_url_twice

    def it_should_handle_the_collison_and_insert_the_url_twice(self):
        uow = inject.instance('UnitOfWorkManager')
        with uow.start() as tx:
            s_url1 = tx.short_urls.get('SID-123')
            s_url2 = tx.short_urls.get('SID-321')

        expect(s_url1.url).to(equal(self.url))
        expect(s_url2.url).to(equal(self.url))
开发者ID:ekiourk,项目名称:yatu,代码行数:8,代码来源:test_url_creation.py


示例15: test_set_blocking_changes_fd_flags

def test_set_blocking_changes_fd_flags():
    with tempfile.TemporaryFile() as f:
        io.set_blocking(f, False)
        flags = fcntl.fcntl(f, fcntl.F_GETFL)
        expect(flags & os.O_NONBLOCK).to(equal(os.O_NONBLOCK))

        io.set_blocking(f, True)
        flags = fcntl.fcntl(f, fcntl.F_GETFL)
        expect(flags & os.O_NONBLOCK).to(equal(0))
开发者ID:bschmeck,项目名称:dockerpty,代码行数:9,代码来源:test_io.py


示例16: test_should_add_expected_label_as_report_request

 def test_should_add_expected_label_as_report_request(self):
     timer = _DateTimeTimer()
     rules = report_request.ReportingRules(labels=[
         _EXPECTED_OK_LABEL
     ])
     for info, want in _ADD_LABELS_TESTS:
         got = info.as_report_request(rules, timer=timer)
         expect(got.serviceName).to(equal(_TEST_SERVICE_NAME))
         expect(got.reportRequest.operations[0]).to(equal(want))
开发者ID:catapult-project,项目名称:catapult,代码行数:9,代码来源:test_report_request.py


示例17: test_should_use_the_latest_end_time_delta_merges

 def test_should_use_the_latest_end_time_delta_merges(self):
     got = metric_value.merge(MetricKind.DELTA,
                              self.early_ending,
                              self.late_ending)
     expect(got.endTime).to(equal(self.late_ending.endTime))
     got = metric_value.merge(MetricKind.DELTA,
                              self.late_ending,
                              self.early_ending)
     expect(got.endTime).to(equal(self.late_ending.endTime))
开发者ID:catapult-project,项目名称:catapult,代码行数:9,代码来源:test_metric_value.py


示例18: test_should_convert_using_as_quota_request

 def test_should_convert_using_as_quota_request(self):
     timer = _DateTimeTimer()
     for info, want in _INFO_TESTS:
         got = info.as_allocate_quota_request(timer=timer)
         # These additional properties have no well-defined order, so sort them.
         got.allocateQuotaRequest.allocateOperation.labels.additionalProperties.sort(key=KEYGETTER)
         want.labels.additionalProperties.sort(key=KEYGETTER)
         expect(got.allocateQuotaRequest.allocateOperation).to(equal(want))
         expect(got.serviceName).to(equal(_TEST_SERVICE_NAME))
开发者ID:AndreaBuffa,项目名称:trenordsaga,代码行数:9,代码来源:test_quota_request.py


示例19: test_should_detect_nothing_for_methods_with_no_registration

 def test_should_detect_nothing_for_methods_with_no_registration(self):
     registry = self._get_registry()
     info = registry.lookup(u'GET', u'uvw/default_parameters')
     expect(info).not_to(be_none)
     expect(info.selector).to(equal(u'Uvw.DefaultParameters'))
     expect(info.url_query_param(u'name1')).to(equal(tuple()))
     expect(info.url_query_param(u'name2')).to(equal(tuple()))
     expect(info.header_param(u'name1')).to(equal(tuple()))
     expect(info.header_param(u'name2')).to(equal(tuple()))
开发者ID:AndreaBuffa,项目名称:trenordsaga,代码行数:9,代码来源:test_service.py


示例20: test_should_add_ok_when_nanos_have_different_signs

 def test_should_add_ok_when_nanos_have_different_signs(self):
     the_sum = money.add(self._SOME_YEN, self._SOME_YEN_DEBT)
     want_units = self._SOME_YEN_DEBT.units + self._SOME_YEN.units - 1
     expect(the_sum.units).to(equal(want_units))
     expect(the_sum.nanos).to(equal(money.MAX_NANOS))
     the_sum = money.add(self._SOME_MORE_YEN, self._SOME_YEN_DEBT)
     want_units = self._SOME_YEN_DEBT.units + self._SOME_YEN.units - 1
     expect(the_sum.units).to(equal(want_units))
     expect(the_sum.nanos).to(equal(1 - money.MAX_NANOS))
开发者ID:catapult-project,项目名称:catapult,代码行数:9,代码来源:test_money.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python expects.expect函数代码示例发布时间:2022-05-24
下一篇:
Python expect.raises函数代码示例发布时间: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