当前位置: 首页>>代码示例>>Python>>正文


Python cookies.morsel_to_cookie函数代码示例

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


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

示例1: test_max_age_invalid_str

    def test_max_age_invalid_str(self):
        """Test case where a invalid max age is passed."""

        morsel = Morsel()
        morsel["max-age"] = "woops"
        with pytest.raises(TypeError):
            morsel_to_cookie(morsel)
开发者ID:RRedwards,项目名称:requests,代码行数:7,代码来源:test_requests.py

示例2: test_expires_invalid_str

    def test_expires_invalid_str(self):
        """Test case where an invalid string is input."""

        morsel = Morsel()
        morsel["expires"] = "woops"
        with pytest.raises(ValueError):
            morsel_to_cookie(morsel)
开发者ID:RRedwards,项目名称:requests,代码行数:7,代码来源:test_requests.py

示例3: test_expires_invalid_int

    def test_expires_invalid_int(self):
        """Test case where an invalid type is passed for expires."""

        morsel = Morsel()
        morsel["expires"] = 100
        with pytest.raises(TypeError):
            morsel_to_cookie(morsel)
开发者ID:RRedwards,项目名称:requests,代码行数:7,代码来源:test_requests.py

示例4: test_max_age_valid_int

    def test_max_age_valid_int(self):
        """Test case where a valid max age in seconds is passed."""

        morsel = Morsel()
        morsel["max-age"] = 60
        cookie = morsel_to_cookie(morsel)
        assert isinstance(cookie.expires, int)
开发者ID:RRedwards,项目名称:requests,代码行数:7,代码来源:test_requests.py

示例5: test_expires_none

    def test_expires_none(self):
        """Test case where expires is None."""

        morsel = Morsel()
        morsel["expires"] = None
        cookie = morsel_to_cookie(morsel)
        assert cookie.expires is None
开发者ID:RRedwards,项目名称:requests,代码行数:7,代码来源:test_requests.py

示例6: test_expires_valid_str

    def test_expires_valid_str(self):
        """Test case where we convert expires from string time."""

        morsel = Morsel()
        morsel["expires"] = "Thu, 01-Jan-1970 00:00:01 GMT"
        cookie = morsel_to_cookie(morsel)
        assert cookie.expires == 1
开发者ID:RRedwards,项目名称:requests,代码行数:7,代码来源:test_requests.py

示例7: proceed

 def proceed(self):
     script = self.doc.xpath('//script/text()')[0]
     cookieStr = re.match('.*document\.cookie = "([^"]+)".*',
                          script, re.DOTALL).group(1)
     morsel = Cookie.Cookie(cookieStr).values()[0]
     self.browser.session.cookies.set_cookie(morsel_to_cookie(morsel))
     form = self.get_form()
     return form.submit()
开发者ID:frankrousseau,项目名称:weboob-modules,代码行数:8,代码来源:pages.py

示例8: test_expires_invalid_int

 def test_expires_invalid_int(self, value, exception):
     """Test case where an invalid type is passed for expires."""
     morsel = Morsel()
     morsel['expires'] = value
     with pytest.raises(exception):
         morsel_to_cookie(morsel)
开发者ID:503945930,项目名称:requests,代码行数:6,代码来源:test_requests.py


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