diff --git a/CHANGES/5840.bugfix b/CHANGES/5840.bugfix new file mode 100644 index 00000000000..7380aa246f2 --- /dev/null +++ b/CHANGES/5840.bugfix @@ -0,0 +1 @@ +Remove external test dependency to http://httpbin.org diff --git a/tests/test_formdata.py b/tests/test_formdata.py index 4655f484464..e1c642c65c3 100644 --- a/tests/test_formdata.py +++ b/tests/test_formdata.py @@ -4,7 +4,7 @@ import pytest -from aiohttp import ClientSession, FormData +from aiohttp import FormData, web @pytest.fixture @@ -88,16 +88,22 @@ async def test_formdata_field_name_is_not_quoted(buf: Any, writer: Any) -> None: assert b'name="email 1"' 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()