Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_post(server):
with httpcore.SyncClient() as http:
response = http.post("http://127.0.0.1:8000/", data=b"Hello, world!")
assert response.status_code == 200
assert response.reason_phrase == "OK"
def test_get(server):
with httpcore.SyncClient() as http:
response = http.get("http://127.0.0.1:8000/")
assert response.status_code == 200
assert response.content == b"Hello, world!"
assert response.text == "Hello, world!"
def test_stream_response(server):
with httpcore.SyncClient() as http:
response = http.get("http://127.0.0.1:8000/", stream=True)
assert response.status_code == 200
content = response.read()
assert content == b"Hello, world!"
def test_stream_iterator(server):
with httpcore.SyncClient() as http:
response = http.get("http://127.0.0.1:8000/", stream=True)
assert response.status_code == 200
body = b""
for chunk in response.stream():
body += chunk
assert body == b"Hello, world!"
def test_raw_iterator(server):
with httpcore.SyncClient() as http:
response = http.get("http://127.0.0.1:8000/", stream=True)
assert response.status_code == 200
body = b""
for chunk in response.raw():
body += chunk
assert body == b"Hello, world!"