Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make prettier urls if query is empty dict #1143

Merged
merged 1 commit into from
Sep 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aiohttp/web_urldispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions tests/test_client_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -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@' +
Expand Down