Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.3k
#650 Add Type-Check to test#870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,27 @@ | ||
| import typing | ||
| import pytest | ||
| from uvicorn.main import Server | ||
| import httpx | ||
| def test_get(server): | ||
| def test_get(server: Server) -> None: | ||
| response = httpx.get(server.url) | ||
| assert response.status_code == 200 | ||
| assert response.reason_phrase == "OK" | ||
| assert response.text == "Hello, world!" | ||
| assert response.http_version == "HTTP/1.1" | ||
| def test_post(server): | ||
| def test_post(server: Server) -> None: | ||
| response = httpx.post(server.url, data=b"Hello, world!") | ||
| assert response.status_code == 200 | ||
| assert response.reason_phrase == "OK" | ||
| def test_post_byte_iterator(server): | ||
| def data(): | ||
| def test_post_byte_iterator(server: Server) -> None: | ||
| def data() -> typing.Generator[bytes, None, None]: | ||
| yield b"Hello" | ||
| yield b", " | ||
| yield b"world!" | ||
| @@ -28,37 +31,37 @@ def data(): | ||
| assert response.reason_phrase == "OK" | ||
| def test_options(server): | ||
| def test_options(server: Server) -> None: | ||
| response = httpx.options(server.url) | ||
| assert response.status_code == 200 | ||
| assert response.reason_phrase == "OK" | ||
| def test_head(server): | ||
| def test_head(server: Server) -> None: | ||
| response = httpx.head(server.url) | ||
| assert response.status_code == 200 | ||
| assert response.reason_phrase == "OK" | ||
| def test_put(server): | ||
| def test_put(server: Server) -> None: | ||
| response = httpx.put(server.url, data=b"Hello, world!") | ||
| assert response.status_code == 200 | ||
| assert response.reason_phrase == "OK" | ||
| def test_patch(server): | ||
| def test_patch(server: Server) -> None: | ||
| response = httpx.patch(server.url, data=b"Hello, world!") | ||
| assert response.status_code == 200 | ||
| assert response.reason_phrase == "OK" | ||
| def test_delete(server): | ||
| def test_delete(server: Server) -> None: | ||
| response = httpx.delete(server.url) | ||
| assert response.status_code == 200 | ||
| assert response.reason_phrase == "OK" | ||
| def test_stream(server): | ||
| def test_stream(server: Server) -> None: | ||
| with httpx.stream("GET", server.url) as response: | ||
| response.read() | ||
| @@ -69,6 +72,6 @@ def test_stream(server): | ||
| @pytest.mark.asyncio | ||
| async def test_get_invalid_url(server): | ||
| async def test_get_invalid_url(server: Server) -> None: | ||
| with pytest.raises(httpx.InvalidURL): | ||
| await httpx.get("invalid://example.org") | ||
| await httpx.get("invalid://example.org") # type:ignore | ||
Comment on lines
74
to
+77
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, so this entire test should really not be an | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we prefer this more relaxed style, in line with our other typing usage in this repo?