def test_bad_port(): try: E.encode_uri('http://foo.bar:buz') except E.MalformedUrlError as error: assert error.args == ( "Invalid port number: invalid literal for int() with base 10: 'buz'", )
def test_bad_domain_segment_too_long(): try: E.encode_uri('http://foo.%s.bar' % ('x' * 64)) except E.MalformedUrlError as error: assert error.args == ( "Invalid hostname: label empty or too long: " + "'foo.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.bar'", )
def test_bad_domain_segment_too_long(): try: E.encode_uri('http://foo.%s.bar' % ('x' * 64)) except E.MalformedUrlError as error: assert error.args == ( "Invalid hostname: label empty or too long: " + "'foo.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.bar'", )
def test_bad_domain_segment_too_long(): try: E.encode_uri('http://foo.%s.bar' % ('x' * 64)) except E.MalformedUrlError as error: if six.PY3: error_msg = ("Invalid hostname: encoding with 'IDNA' codec failed " "(UnicodeError: label empty or too long): ") else: error_msg = 'Invalid hostname: label empty or too long: ' assert error.args == (error_msg + repr( u"foo.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.bar" ), )
def test_bad_domain_segment_too_long(): try: E.encode_uri('http://foo.%s.bar' % ('x' * 64)) except E.MalformedUrlError as error: if six.PY3: error_msg = ( "Invalid hostname: encoding with 'IDNA' codec failed " "(UnicodeError: label empty or too long): " ) else: error_msg = 'Invalid hostname: label empty or too long: ' assert error.args == ( error_msg + repr(u"foo.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.bar"), )
def test_bad_domain_extra_dots(): # We normalize this one ala Chrome browser assert E.encode_uri('http://..foo..com../.bar.') == 'http://foo.com/.bar.'
def test_bad_domain_extra_dots(): # We normalize this one ala Chrome browser assert E.encode_uri('http://..foo..com../.bar.') == 'http://foo.com/.bar.'
def test_bad_port(): try: E.encode_uri('http://foo.bar:buz') except E.MalformedUrlError as error: assert error.args == ("Invalid port number: invalid literal for int() with base 10: 'buz'",)