Skip to content

Commit 728505c

Browse files

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

CHANGES/5840.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove external test dependency to http://httpbin.org

tests/test_formdata.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import pytest
66

7-
from aiohttp import ClientSession, FormData
7+
from aiohttp import FormData, web
88

99

1010
@pytest.fixture
@@ -88,16 +88,22 @@ async def test_formdata_field_name_is_not_quoted(buf: Any, writer: Any) -> None:
8888
assert b'name="email 1"' in buf
8989

9090

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

97-
resp = await session.post(url, data=data)
98-
assert len(data._writer._parts) == 1
95+
app = web.Application()
96+
app.add_routes([web.post("/", handler)])
9997

100-
with pytest.raises(RuntimeError):
101-
await session.post(url, data=data)
98+
client = await aiohttp_client(app)
10299

103-
resp.release()
100+
data = FormData()
101+
data.add_field("test", "test_value", content_type="application/json")
102+
103+
resp = await client.post("/", data=data)
104+
assert len(data._writer._parts) == 1
105+
106+
with pytest.raises(RuntimeError):
107+
await client.post("/", data=data)
108+
109+
resp.release()

0 commit comments

Comments
 (0)