Enhance test coverage for httpx requests

Add tests for invalid request schemes and missing host.
This commit is contained in:
Kim Christie 2025-12-17 12:52:50 +00:00 committed by GitHub
parent ae25e86f5c
commit 39db171721
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,4 +1,5 @@
import httpx
import pytest
class ByteIterator:
@ -77,3 +78,13 @@ def test_request_empty_post():
"Content-Length": "0",
}
assert r.read() == b''
def test_request_invalid_scheme():
with pytest.raises(ValueError):
httpx.Request("GET", "ws://example.com")
def test_request_missing_host():
with pytest.raises(ValueError):
r = httpx.Request("GET", "https:/example.com")