From d2d0edbab6e9447c4e3319c3ad16c3c2b58deaf0 Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Fri, 20 Oct 2017 15:00:38 +0330 Subject: [PATCH] Improve parse_address utils tests --- tests/test_util.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_util.py b/tests/test_util.py index fbd0aa21a8..9deb05c43a 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -3,6 +3,8 @@ # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. +import pytest + from gunicorn import util @@ -10,3 +12,13 @@ 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)