예제 #1
0
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!"
예제 #2
0
def test_post(server):
    with httpcore.SyncClient() as http:
        response = http.post("http://127.0.0.1:8000/", content=b"Hello, world!")
    assert response.status_code == 200
    assert response.reason_phrase == "OK"
예제 #3
0
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!"
예제 #4
0
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!"