コード例 #1
0
def test_cookie_jar_check_cookies_removes_expired():
    jar = CookieJar()

    # simulate an expired cookie that gets removed
    jar._domain_cookies

    jar._host_only_cookies = {
        b"foo.org": {
            b"/": {
                b"hello":
                StoredCookie(
                    Cookie(b"hello",
                           b"world",
                           expires=b"Fri, 17 Aug 2018 20:55:04 GMT"))
            }
        }
    }

    list(
        jar._get_cookies_checking_exp(
            b"https", jar._host_only_cookies[b"foo.org"][b"/"]))
    assert jar.get(b"foo.org", b"/", b"hello") is None
コード例 #2
0
def test_cookie_jar_check_cookies_removes_expired():
    jar = CookieJar()

    # simulate an expired cookie that gets removed
    jar._domain_cookies

    jar._host_only_cookies = {
        "foo.org": {
            "/": {
                "hello": StoredCookie(
                    Cookie(
                        "hello",
                        "world",
                        expires=datetime_from_cookie_format(
                            b"Fri, 17 Aug 2018 20:55:04 GMT"
                        ),
                    )
                )
            }
        }
    }

    list(jar._get_cookies_checking_exp("https", jar._host_only_cookies["foo.org"]["/"]))
    assert jar.get("foo.org", "/", "hello") is None