@@ -461,6 +461,27 @@ def test_noslash(self):
461461 self .assertEqual (urllib .parse .urlparse ("http://example.com?blahblah=/foo" ),
462462 ('http' , 'example.com' , '' , '' , 'blahblah=/foo' , '' ))
463463
464+ def test_withoutscheme (self ):
465+ # Test urlparse without scheme
466+ # Issue 754016: urlparse goes wrong with IP:port without scheme
467+ # RFC 1808 specifies that netloc should start with //, urlparse expects
468+ # the same, otherwise it classifies the portion of url as path.
469+ self .assertEqual (urllib .parse .urlparse ("path" ),
470+ ('' ,'' ,'path' ,'' ,'' ,'' ))
471+ self .assertEqual (urllib .parse .urlparse ("//www.python.org:80" ),
472+ ('' ,'www.python.org:80' ,'' ,'' ,'' ,'' ))
473+ self .assertEqual (urllib .parse .urlparse ("http://www.python.org:80" ),
474+ ('http' ,'www.python.org:80' ,'' ,'' ,'' ,'' ))
475+
476+ def test_portseparator (self ):
477+ # Issue 754016 makes changes for port separator ':' from scheme separator
478+ self .assertEqual (urllib .parse .urlparse ("path:80" ),
479+ ('' ,'' ,'path:80' ,'' ,'' ,'' ))
480+ self .assertEqual (urllib .parse .urlparse ("http:" ),('http' ,'' ,'' ,'' ,'' ,'' ))
481+ self .assertEqual (urllib .parse .urlparse ("https:" ),('https' ,'' ,'' ,'' ,'' ,'' ))
482+ self .assertEqual (urllib .parse .urlparse ("http://www.python.org:80" ),
483+ ('http' ,'www.python.org:80' ,'' ,'' ,'' ,'' ))
484+
464485 def test_usingsys (self ):
465486 # Issue 3314: sys module is used in the error
466487 self .assertRaises (TypeError , urllib .parse .urlencode , "foo" )
0 commit comments