|
5 | 5 | import unittest
|
6 | 6 | import tempfile
|
7 | 7 | from aiohttp import web, request, FormData
|
| 8 | +from aiohttp.multidict import MultiDict |
8 | 9 |
|
9 | 10 |
|
10 | 11 | class TestWebFunctional(unittest.TestCase):
|
@@ -267,3 +268,24 @@ def go(tmpdirname, filename):
|
267 | 268 | fp.flush()
|
268 | 269 | fp.seek(0)
|
269 | 270 | self.loop.run_until_complete(go(tmpdirname, filename))
|
| 271 | + |
| 272 | + def test_post_form_with_duplicate_keys(self): |
| 273 | + |
| 274 | + @asyncio.coroutine |
| 275 | + def handler(request): |
| 276 | + data = yield from request.POST() |
| 277 | + lst = list(sorted(data.items(getall=True))) |
| 278 | + self.assertEqual([('a', '1'), ('a', '2')], lst) |
| 279 | + return web.Response(request, b'OK') |
| 280 | + |
| 281 | + @asyncio.coroutine |
| 282 | + def go(): |
| 283 | + _, _, url = yield from self.create_server('POST', '/', handler) |
| 284 | + resp = yield from request('POST', url, |
| 285 | + data=MultiDict([('a', 1), ('a', 2)]), |
| 286 | + loop=self.loop) |
| 287 | + self.assertEqual(200, resp.status) |
| 288 | + txt = yield from resp.text() |
| 289 | + self.assertEqual('OK', txt) |
| 290 | + |
| 291 | + self.loop.run_until_complete(go()) |
0 commit comments