|
4 | 4 |
|
5 | 5 | import pytest |
6 | 6 |
|
7 | | -from aiohttp import ClientSession, FormData |
| 7 | +from aiohttp import FormData, web |
8 | 8 |
|
9 | 9 |
|
10 | 10 | @pytest.fixture |
@@ -88,16 +88,22 @@ async def test_formdata_field_name_is_not_quoted(buf: Any, writer: Any) -> None: |
88 | 88 | assert b'name="email 1"' in buf |
89 | 89 |
|
90 | 90 |
|
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() |
96 | 94 |
|
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)]) |
99 | 97 |
|
100 | | - with pytest.raises(RuntimeError): |
101 | | - await session.post(url, data=data) |
| 98 | + client = await aiohttp_client(app) |
102 | 99 |
|
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