Skip to content

Commit

Permalink
Remove external test dependency to http://httpbin.org (#5843)
Browse files Browse the repository at this point in the history
(cherry picked from commit 728505c)
  • Loading branch information
derlih authored and Patchback committed Oct 20, 2021
1 parent e31179d commit cb476e8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGES/5840.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove external test dependency to http://httpbin.org
28 changes: 17 additions & 11 deletions tests/test_formdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from aiohttp import ClientSession, FormData
from aiohttp import FormData, web


@pytest.fixture
Expand Down Expand Up @@ -86,16 +86,22 @@ async def test_formdata_field_name_is_not_quoted(buf, writer) -> None:
assert b'name="emails[]"' in buf


async def test_mark_formdata_as_processed() -> None:
async with ClientSession() as session:
url = "http://httpbin.org/anything"
data = FormData()
data.add_field("test", "test_value", content_type="application/json")
async def test_mark_formdata_as_processed(aiohttp_client: Any) -> None:
async def handler(request):
return web.Response()

resp = await session.post(url, data=data)
assert len(data._writer._parts) == 1
app = web.Application()
app.add_routes([web.post("/", handler)])

with pytest.raises(RuntimeError):
await session.post(url, data=data)
client = await aiohttp_client(app)

resp.release()
data = FormData()
data.add_field("test", "test_value", content_type="application/json")

resp = await client.post("/", data=data)
assert len(data._writer._parts) == 1

with pytest.raises(RuntimeError):
await client.post("/", data=data)

resp.release()

0 comments on commit cb476e8

Please sign in to comment.