Skip to content
This repository has been archived by the owner on Sep 27, 2019. It is now read-only.

Commit

Permalink
Add test for streaming requests
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchristie committed Apr 19, 2019
1 parent d419411 commit 6bcd814
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/test_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,16 @@ async def test_iter_lines_with_delimiter(server):
async for line in response.iter_lines(decode_unicode=True, delimiter=" "):
lines.append(line)
assert lines == ["Hello,", "world!"]


@pytest.mark.asyncio
async def test_stream_request(server):
url = "http://127.0.0.1:8000/"

async def stream():
yield b"e"
yield b"xample"

response = await requests_async.post(url, data=stream())
assert response.status_code == 200
assert response.json() == {"method": "POST", "url": url, "body": "example"}

0 comments on commit 6bcd814

Please sign in to comment.