Пример #1
0
def test_get_cookies_for_url_ignores_secure_cookies_for_http():
    jar = CookieJar()

    jar.add(URL(b"https://foo.org"), Cookie(b"hello", b"world", secure=True))

    cookies = list(jar.get_cookies_for_url(URL(b"http://foo.org/hello-world")))
    assert len(cookies) == 0
Пример #2
0
def test_get_cookies_for_url():
    jar = CookieJar()

    jar.add(URL(b"https://foo.org"), Cookie("hello", "world"))

    cookies = list(jar.get_cookies_for_url(URL(b"https://foo.org/hello-world")))

    assert len(cookies) == 1
    assert cookies[0].name == "hello"
    assert cookies[0].value == "world"
Пример #3
0
def test_get_cookies_for_url():
    jar = CookieJar()

    jar.add(URL(b'https://foo.org'), Cookie(b'hello', b'world'))

    cookies = list(jar.get_cookies_for_url(
        URL(b'https://foo.org/hello-world')))

    assert len(cookies) == 1
    assert cookies[0].name == b'hello'
    assert cookies[0].value == b'world'
Пример #4
0
def test_cookie_jar_throws_for_url_without_host():
    jar = CookieJar()

    with pytest.raises(MissingSchemeInURL):
        jar.get_cookies_for_url(URL(b"/"))