fix url.parse tests for Python 3.6

This is a simpler version of @Kriechi's patch.
This commit is contained in:
Maximilian Hils 2016-12-27 19:09:43 +01:00
parent 51d57cfd4a
commit c78ffbf16d

View File

@ -1,3 +1,6 @@
import pytest
import sys
from mitmproxy.test import tutils
from mitmproxy.net.http import url
@ -42,14 +45,18 @@ def test_parse():
# Null byte in host
with tutils.raises(ValueError):
url.parse("http://foo\0")
# Port out of range
_, _, port, _ = url.parse("http://foo:999999")
assert port == 80
# Invalid IPv6 URL - see http://www.ietf.org/rfc/rfc2732.txt
with tutils.raises(ValueError):
url.parse('http://lo[calhost')
@pytest.mark.skipif(sys.version_info < (3, 6), reason='requires Python 3.6 or higher')
def test_parse_port_range():
# Port out of range
with tutils.raises(ValueError):
url.parse("http://foo:999999")
def test_unparse():
assert url.unparse("http", "foo.com", 99, "") == "http://foo.com:99"
assert url.unparse("http", "foo.com", 80, "/bar") == "http://foo.com/bar"