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

Improve parse_address utils tests #1629

Merged
merged 3 commits into from
Oct 22, 2017
Merged
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
23 changes: 19 additions & 4 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,25 @@
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.

import pytest

from gunicorn import util


def test_parse_address():
# Test unix socket addresses (PR #1623)
assert util.parse_address('unix://var/run/test.sock') == 'var/run/test.sock'
assert util.parse_address('unix:/var/run/test.sock') == '/var/run/test.sock'
@pytest.mark.parametrize('test_input, expected', [
('unix://var/run/test.sock', 'var/run/test.sock'),
('unix:/var/run/test.sock', '/var/run/test.sock'),
('', ('0.0.0.0', 8000)),
('[::1]:8000', ('::1', 8000)),
('localhost:8000', ('localhost', 8000)),
('127.0.0.1:8000', ('127.0.0.1', 8000)),
('localhost', ('localhost', 8000))
])
def test_parse_address(test_input, expected):
assert util.parse_address(test_input) == expected


def test_parse_address_invalid():
with pytest.raises(RuntimeError) as err:
util.parse_address('127.0.0.1:test')
assert "'test' is not a valid port number." in str(err)