Type-check test_cookies.py (#677)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Florimond Manca · committed by GitHub · parent 49e4d15 · Browse files · 1 file·+11 added−9 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+11 added−9 removed
- tests:+11 added−9 removed
Provenance
- Commit
0ee0005- Tree
c37c477- Author
Florimond Manca <florimond.manca@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
49e4d15
1 file changed+11 added−9 removed
modified:tests/client/test_cookies.py+11 added-9 removed
20 unmodified lines21 return Response(200, content=body, request=request)22 elif request.url.path.startswith("/set_cookie"):23 headers = {"set-cookie": "example-name=example-value"}24 return Response(200, headers=headers, request=request)25+ else:26+ raise NotImplementedError # pragma: no cover27 28 29 @pytest.mark.asyncio28-async def test_set_cookie():30+async def test_set_cookie() -> None:31 """32 Send a request including a cookie.33 """34 url = "http://example.org/echo_cookies"6 unmodified lines41 assert response.json() == {"cookies": "example-name=example-value"}42 43 44 @pytest.mark.asyncio43-async def test_set_cookie_with_cookiejar():45+async def test_set_cookie_with_cookiejar() -> None:46 """47 Send a request including a cookie, using a `CookieJar` instance.48 """49 14 unmodified lines64 expires=None,65 discard=True,66 comment=None,67 comment_url=None,66- rest={"HttpOnly": None},68+ rest={"HttpOnly": ""},69 rfc2109=False,70 )71 cookies.set_cookie(cookie)72 4 unmodified lines77 assert response.json() == {"cookies": "example-name=example-value"}78 79 80 @pytest.mark.asyncio79-async def test_setting_client_cookies_to_cookiejar():81+async def test_setting_client_cookies_to_cookiejar() -> None:82 """83 Send a request including a cookie, using a `CookieJar` instance.84 """85 14 unmodified lines100 expires=None,101 discard=True,102 comment=None,103 comment_url=None,102- rest={"HttpOnly": None},104+ rest={"HttpOnly": ""},105 rfc2109=False,106 )107 cookies.set_cookie(cookie)108 109 client = Client(dispatch=MockDispatch())108- client.cookies = cookies110+ client.cookies = cookies # type: ignore111 response = await client.get(url)112 113 assert response.status_code == 200114 assert response.json() == {"cookies": "example-name=example-value"}115 116 117 @pytest.mark.asyncio116-async def test_set_cookie_with_cookies_model():118+async def test_set_cookie_with_cookies_model() -> None:119 """120 Send a request including a cookie, using a `Cookies` instance.121 """122 8 unmodified lines131 assert response.json() == {"cookies": "example-name=example-value"}132 133 134 @pytest.mark.asyncio133-async def test_get_cookie():135+async def test_get_cookie() -> None:136 url = "http://example.org/set_cookie"137 138 client = Client(dispatch=MockDispatch())139 response = await client.get(url)3 unmodified lines143 assert client.cookies["example-name"] == "example-value"144 145 146 @pytest.mark.asyncio145-async def test_cookie_persistence():147+async def test_cookie_persistence() -> None:148 """149 Ensure that Client instances persist cookies between requests.150 """151 client = Client(dispatch=MockDispatch())13 unmodified lines