From c78ffbf16dd8684261652d2de91d8950eea037e9 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Tue, 27 Dec 2016 19:09:43 +0100 Subject: fix url.parse tests for Python 3.6 This is a simpler version of @Kriechi's patch. --- test/mitmproxy/net/http/test_url.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/test/mitmproxy/net/http/test_url.py b/test/mitmproxy/net/http/test_url.py index 94b2eacc..5f85112b 100644 --- a/test/mitmproxy/net/http/test_url.py +++ b/test/mitmproxy/net/http/test_url.py @@ -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" -- cgit v1.2.3