mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-30 03:14:22 +00:00
fix url.parse tests for Python 3.6
This is a simpler version of @Kriechi's patch.
This commit is contained in:
parent
51d57cfd4a
commit
c78ffbf16d
@ -1,3 +1,6 @@
|
|||||||
|
import pytest
|
||||||
|
import sys
|
||||||
|
|
||||||
from mitmproxy.test import tutils
|
from mitmproxy.test import tutils
|
||||||
from mitmproxy.net.http import url
|
from mitmproxy.net.http import url
|
||||||
|
|
||||||
@ -42,14 +45,18 @@ def test_parse():
|
|||||||
# Null byte in host
|
# Null byte in host
|
||||||
with tutils.raises(ValueError):
|
with tutils.raises(ValueError):
|
||||||
url.parse("http://foo\0")
|
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
|
# Invalid IPv6 URL - see http://www.ietf.org/rfc/rfc2732.txt
|
||||||
with tutils.raises(ValueError):
|
with tutils.raises(ValueError):
|
||||||
url.parse('http://lo[calhost')
|
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():
|
def test_unparse():
|
||||||
assert url.unparse("http", "foo.com", 99, "") == "http://foo.com:99"
|
assert url.unparse("http", "foo.com", 99, "") == "http://foo.com:99"
|
||||||
assert url.unparse("http", "foo.com", 80, "/bar") == "http://foo.com/bar"
|
assert url.unparse("http", "foo.com", 80, "/bar") == "http://foo.com/bar"
|
||||||
|
Loading…
Reference in New Issue
Block a user