Skip to content

Commit

Permalink
Improve parse_address utils tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hramezani committed Oct 21, 2017
1 parent 81efa40 commit d2d0edb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,22 @@
# 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'

assert util.parse_address('') == ('0.0.0.0', 8000)
assert util.parse_address('[::1]:8000') == ('::1', 8000)
assert util.parse_address('localhost:8000') == ('localhost', 8000)
assert util.parse_address('127.0.0.1:8000') == ('127.0.0.1', 8000)
assert util.parse_address('localhost') == ('localhost', 8000)

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

0 comments on commit d2d0edb

Please sign in to comment.