diff --git a/aiohttp/web_urldispatcher.py b/aiohttp/web_urldispatcher.py index 7b288fede24..336cac748d0 100644 --- a/aiohttp/web_urldispatcher.py +++ b/aiohttp/web_urldispatcher.py @@ -59,7 +59,7 @@ def get_info(self): @staticmethod def _append_query(url, query): - if query is not None: + if query: return url + "?" + urlencode(query) else: return url diff --git a/tests/test_client_request.py b/tests/test_client_request.py index b413570a873..c68d3b0ba21 100644 --- a/tests/test_client_request.py +++ b/tests/test_client_request.py @@ -405,6 +405,15 @@ def test_params_update_path_and_url(make_request): assert req.url == 'http://python.org/?test=foo&test=baz' +def test_params_empty_path_and_url(make_request): + req_empty = make_request('get', 'http://python.org', params={}) + assert req_empty.path == '/' + assert req_empty.url == 'http://python.org/' + req_none = make_request('get', 'http://python.org') + assert req_none.path == '/' + assert req_none.url == 'http://python.org/' + + def test_gen_netloc_all(make_request): req = make_request('get', 'https://aiohttp:pwpwpw@' +