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

Python sure.expect函数代码示例

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

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



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

示例1: test_get_missing_backend

 def test_get_missing_backend(self):
     backend = get_backend((
         'social.backends.github.GithubOAuth2',
         'social.backends.facebook.FacebookOAuth2',
         'social.backends.flickr.FlickrOAuth'
     ), 'foobar')
     expect(backend).to.equal(None)
开发者ID:CodersClan,项目名称:python-social-auth,代码行数:7,代码来源:utils_tests.py


示例2: test_httpretty_should_allow_adding_and_overwritting_by_kwargs_u2

def test_httpretty_should_allow_adding_and_overwritting_by_kwargs_u2(now):
    u"HTTPretty should allow adding and overwritting headers by keyword args " \
        "with httplib2"

    HTTPretty.register_uri(HTTPretty.GET, "http://github.com/foo",
                           body="this is supposed to be the response",
                           server='Apache',
                           content_length='27',
                           content_type='application/json')

    headers, _ = httplib2.Http().request('http://github.com/foo', 'GET')

    expect(dict(headers)).to.equal({
        'content-type': 'application/json',
        'content-location': 'http://github.com/foo',  # httplib2 FORCES
                                                   # content-location
                                                   # even if the
                                                   # server does not
                                                   # provide it
        'connection': 'close',
        'content-length': '27',
        'status': '200',
        'server': 'Apache',
        'date': now.strftime('%a, %d %b %Y %H:%M:%S GMT'),
    })
开发者ID:hughsaunders,项目名称:HTTPretty,代码行数:25,代码来源:test_httplib2.py


示例3: test_callback_response

def test_callback_response(now):
    ("HTTPretty should call a callback function and set its return value as the body of the response"
     " requests")

    def request_callback(request, uri, headers):
        return [200, headers, "The {} response from {}".format(decode_utf8(request.method), uri)]

    HTTPretty.register_uri(
        HTTPretty.GET, "https://api.yahoo.com/test",
        body=request_callback)

    response = requests.get('https://api.yahoo.com/test')

    expect(response.text).to.equal("The GET response from https://api.yahoo.com/test")

    HTTPretty.register_uri(
        HTTPretty.POST, "https://api.yahoo.com/test_post",
        body=request_callback)

    response = requests.post(
        "https://api.yahoo.com/test_post",
        {"username": "gabrielfalcao"}
    )

    expect(response.text).to.equal("The POST response from https://api.yahoo.com/test_post")
开发者ID:andresriancho,项目名称:HTTPretty,代码行数:25,代码来源:test_requests.py


示例4: test_equal_with_repr_of_complex_types_and_unicode

def test_equal_with_repr_of_complex_types_and_unicode():
    (u"test usage of repr() inside expect(complex1).to.equal(complex2)")

    class Y(object):
        def __init__(self, x):
            self.x = x

        def __repr__(self):
            if PY3:
                # PY3K should return the regular (unicode) string
                return self.x
            else:
                return self.x.encode('utf-8')

        def __eq__(self, other):
            return self.x == other.x

    y1 = dict(
        a=2,
        b=Y(u'Gabriel Falcão'),
        c='Foo',
    )

    expect(y1).to.equal(dict(
        a=2,
        b=Y(u'Gabriel Falcão'),
        c='Foo',
    ))
开发者ID:amukiza,项目名称:sure,代码行数:28,代码来源:test_assertion_builder.py


示例5: test_fake_socket_passes_through_gettimeout

def test_fake_socket_passes_through_gettimeout():
    import socket
    HTTPretty.enable()
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.truesock = MagicMock()
    expect(s.gettimeout).called_with().should_not.throw(AttributeError)
    s.truesock.gettimeout.assert_called_with()
开发者ID:Gandi,项目名称:HTTPretty,代码行数:7,代码来源:test_httpretty.py


示例6: test_get_not_found

 def test_get_not_found(self):
     not_found = '{"status": 404,"message": "Not Found"}'
     httpretty.register_uri(httpretty.GET, path('/users/user_id'), status=404, body=not_found)
     client = ICMClient.create('my-access-token')
     response = client.users('user_id').GET()
     expect(response.status_code).should.equal(404)
     expect(response.text).should.equal(not_found)
开发者ID:singlewire,项目名称:icm-python-client,代码行数:7,代码来源:test_icm_client.py


示例7: test_list_can_full_page_of_data

 def test_list_can_full_page_of_data(self):
     empty_page = json.dumps({'total': 1, 'next': None, 'previous': None, 'data': [USER]})
     httpretty.register_uri(httpretty.GET, path('/users'), body=empty_page)
     client = ICMClient.create('my-access-token')
     users = client.users().LIST()
     expect(users.next()).should.equal(USER)
     users.next.when.called_with().should.throw(StopIteration)
开发者ID:singlewire,项目名称:icm-python-client,代码行数:7,代码来源:test_icm_client.py


示例8: test_get_email_list_should_not_update_session_id_when_not_included_in_response

 def test_get_email_list_should_not_update_session_id_when_not_included_in_response(self, **kwargs):
     self.setup_mocks(**kwargs)
     self.mock_client.get_email_list.return_value = {'list': []}
     self.session.session_id = 1
     self.session.email_timestamp = current_timestamp()
     self.session.get_email_list()
     expect(self.session.session_id).to.equal(1)
开发者ID:bdpdx,项目名称:python-guerrillamail,代码行数:7,代码来源:tests.py


示例9: test_get_email_list_should_not_refresh_session_when_email_not_expired

 def test_get_email_list_should_not_refresh_session_when_email_not_expired(self, **kwargs):
     self.setup_mocks(**kwargs)
     self.mock_client.get_email_list.return_value = {'list': []}
     self.session.session_id = 1
     self.session.email_timestamp = current_timestamp() - 3590
     self.session.get_email_list()
     expect(self.mock_client.get_email_address.called).to.equal(False)
开发者ID:bdpdx,项目名称:python-guerrillamail,代码行数:7,代码来源:tests.py


示例10: test_get_list_filter_by_user

def test_get_list_filter_by_user():
    # Delete all items
    UserItem.objects.all().delete()
    APIKey.objects.all().delete()
    User.objects.all().delete()
    user = User.objects.create(username='tester', password='123')
    user2 = User.objects.create(username='tester2', password='345')

    # Create 30 items
    for x in range(30):
        UserItem.objects.create(
            name="my name is {}".format(x),
            user=[user, user2][x % 2],
            is_active=x % 2)

    apikey = APIKey.objects.create(user=user)
    response = client.get(reverse('by_user_authorized_item_list'),
                          data={'apikey': apikey.token},
                          content_type='application/json')
    all_items = [
            {
                "id": x + 1,
                "name": "my name is {}".format(x),
                "user_id": [user.id, user2.id][x % 2],
            } for x in range(30)]

    expected_items = [item for item in all_items if item["user_id"] == user.id]
    expected_response_content = {
        "items": expected_items}
    expect(json.loads(response.content)).to.equal(expected_response_content)
    expect(response.status_code).to.equal(200)
开发者ID:suneel0101,项目名称:django-easyrest,代码行数:31,代码来源:test_endpoints.py


示例11: test_get_email_list_should_extract_response_list

 def test_get_email_list_should_extract_response_list(self, **kwargs):
     self.setup_mocks(**kwargs)
     self.mock_client.get_email_list.return_value = {'list': []}
     self.session.session_id = 1
     self.session.email_timestamp = current_timestamp()
     email_list = self.session.get_email_list()
     expect(email_list).to.have.length_of(0)
开发者ID:bdpdx,项目名称:python-guerrillamail,代码行数:7,代码来源:tests.py


示例12: test_get_companies

    def test_get_companies(self):
        data = '''
            {
              "_total": 1,
              "values":  [
                 {
                  "companyType":  {
                    "code": "O",
                    "name": "Self Owned"
                  },
                  "id": 5470551,
                  "logoUrl": "https://media.licdn.com/mpr/mpr/e34...Po.png",
                  "name": "Johni Corp"
                }
              ]
            }
        '''

        httpretty.register_uri(httpretty.GET,
                               TestPyLinkedin.URL_GET_COMPANIES,
                               body=data,
                               content_type="application/json")

        basic_profile = self.linkedin.get_companies()
        data = json.loads(data)
        expect(basic_profile).to.equal(data)
开发者ID:johnidm,项目名称:PyLinkedinAPI,代码行数:26,代码来源:test_linkedin_api.py


示例13: test_process_valid_input

 def test_process_valid_input(self):
     self.test_flow_difference.tdigest_key = Mock()
     self.test_flow_difference.tdigest = Mock()
     self.test_flow_difference.metric_sink.read = self.stub_read_metric_sink_tdigest
     self.test_flow_difference._read_data = self.stub_read_data
     states = self.test_flow_difference.process()
     expect(states).to.be.equal((10, {'flag': 0}))
开发者ID:gitter-badger,项目名称:anna-molly,代码行数:7,代码来源:test_flow_difference.py


示例14: test_be

def test_be():
    ("this(X).should.be(X) when X is a reference to the same object")

    d1 = {}
    d2 = d1
    d3 = {}

    assert isinstance(this(d2).should.be(d1), bool)
    assert this(d2).should.be(d1)
    assert this(d3).should_not.be(d1)

    def wrong_should():
        return this(d3).should.be(d1)

    def wrong_should_not():
        return this(d2).should_not.be(d1)

    expect(wrong_should_not).when.called.should.throw(
        AssertionError,
        '{} should not be the same object as {}, but it is',
    )
    expect(wrong_should).when.called.should.throw(
        AssertionError,
        '{} should be the same object as {}, but it is not',
    )
开发者ID:gitter-badger,项目名称:sure,代码行数:25,代码来源:test_assertion_builder.py


示例15: test_HTTPrettyRequest_queryparam

def test_HTTPrettyRequest_queryparam():
    """ A content-type of x-www-form-urlencoded with a valid queryparam body should return parsed content """
    header = TEST_HEADER % {'content_type': 'application/x-www-form-urlencoded'}
    valid_queryparam = u"hello=world&this=isavalidquerystring"
    valid_results = {'hello': ['world'], 'this': ['isavalidquerystring']}
    request = HTTPrettyRequest(header, valid_queryparam)
    expect(request.parsed_body).to.equal(valid_results)
开发者ID:Charlesdong,项目名称:HTTPretty,代码行数:7,代码来源:test_httpretty.py


示例16: test_callback_response

def test_callback_response(now):
    (u"HTTPretty should all a callback function to be set as the body with"
     " requests")

    def request_callback(method, uri, headers):
        return "The {0} response from {1}".format(method, uri)

    HTTPretty.register_uri(
        HTTPretty.GET, "https://api.yahoo.com/test",
        body=request_callback)

    response = requests.get('https://api.yahoo.com/test')

    expect(response.text).to.equal('The GET response from https://api.yahoo.com/test')

    HTTPretty.register_uri(
        HTTPretty.POST, "https://api.yahoo.com/test_post",
        body=request_callback)

    response = requests.post(
        "https://api.yahoo.com/test_post",
        {"username": "gabrielfalcao"}
    )

    expect(response.text).to.equal("The POST response from https://api.yahoo.com/test_post")
开发者ID:amaudy,项目名称:HTTPretty,代码行数:25,代码来源:test_requests.py


示例17: test_put_unauthorized

 def test_put_unauthorized(self):
     unauthorized = '{"type": "unauthorized","status": 401,"message": "Unauthorized"}'
     httpretty.register_uri(httpretty.PUT, path('/users/user_id'), status=401, body=unauthorized)
     client = ICMClient.create('my-access-token')
     response = client.users('user_id').PUT(params={'name': 'Craig Smith', 'email': '[email protected]'})
     expect(response.status_code).should.equal(401)
     expect(response.text).should.equal(unauthorized)
开发者ID:singlewire,项目名称:icm-python-client,代码行数:7,代码来源:test_icm_client.py


示例18: test_verify

    def test_verify(self):
        doc = {"provider_id" : "nope", "provider": "phone", "phone_code": "4758"}
        with app.test_request_context('/?code=4758'):
            resp = self.provider.verify(doc)

        expect(resp).to.be.none
        expect(doc["status"]).to.equal("confirmed")
开发者ID:itseme,项目名称:api-server,代码行数:7,代码来源:test_sms_provider.py


示例19: test_get_not_unauthorized

 def test_get_not_unauthorized(self):
     unauthorized = '{"type": "unauthorized","status": 401,"message": "Unauthorized"}'
     httpretty.register_uri(httpretty.GET, path('/users/user_id'), status=401, body=unauthorized)
     client = ICMClient.create('my-access-token')
     response = client.users('user_id').GET()
     expect(response.status_code).should.equal(401)
     expect(response.text).should.equal(unauthorized)
开发者ID:singlewire,项目名称:icm-python-client,代码行数:7,代码来源:test_icm_client.py


示例20: test_request_api_for_authentication

def test_request_api_for_authentication(context):
    "SleepyHollow supports requests-based authentication"
    sl = SleepyHollow()
    response = sl.get(context.route_to("/auth/simple"), auth=('lincoln', 'gabriel'))

    response.status_code.should.equal(200)
    expect('Very Simple').to.be.within(response.text)
开发者ID:Yipit,项目名称:sleepyhollow,代码行数:7,代码来源:test_request.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python sure.that函数代码示例发布时间:2022-05-27
下一篇:
Python store.find函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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