From 5c94b5c598a927e860fde8fc0bf50b421b03ddfc Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Sat, 1 Oct 2016 03:29:04 +0700 Subject: [PATCH 1/2] Return URL by .make_url() testing utility --- aiohttp/test_utils.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/aiohttp/test_utils.py b/aiohttp/test_utils.py index 8cffb3d6a21..4c39a9fa97f 100644 --- a/aiohttp/test_utils.py +++ b/aiohttp/test_utils.py @@ -10,6 +10,7 @@ from unittest import mock from multidict import CIMultiDict +from yarl import URL import aiohttp @@ -54,14 +55,22 @@ def start_server(self, **kwargs): if self.server: return self.port = unused_port() - self._root = '{}://{}:{}'.format(self.scheme, self.host, self.port) + self._root = URL('{}://{}:{}'.format(self.scheme, + self.host, + self.port)) self.handler = self.app.make_handler(**kwargs) self.server = yield from self._loop.create_server(self.handler, self.host, self.port) def make_url(self, path): - return self._root + path + assert path.startswith('/') + path = path[1:] + if path.startswith('?'): + # add a query to root path + return self._root.with_query(path[1:]) + else: + return self._root / path @asyncio.coroutine def close(self): From 58e6070d70dc106b329ef2b9f970228565a21372 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Sat, 1 Oct 2016 03:30:19 +0700 Subject: [PATCH 2/2] Update CHANGES --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index dd23dc748af..fde0f75257e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -19,7 +19,7 @@ CHANGES - Accept `yarl.URL` by server redirections #1278 -- +- Return `yarl.URL` by `.make_url()` testing utility #1279 -