def urlsplit(url, scheme='', allow_fragments=True): """Parse a URL using urlparse.urlsplit(), splitting query and fragments. This function papers over Python issue9374 when needed. The parameters are the same as urlparse.urlsplit. """ scheme, netloc, path, query, fragment = urlutils.urlsplit( url, scheme, allow_fragments) if allow_fragments and '#' in path: path, fragment = path.split('#', 1) if '?' in path: path, query = path.split('?', 1) return urlutils.SplitResult(scheme, netloc, path, query, fragment)
def test_urlunsplit(self): url = "http://www.yahoo.com" result = urlutils.urlunsplit(urlutils.urlsplit(url)) self.assertEquals(result, 'http://www.yahoo.com')
def test_urlsplit(self): url = 'http://www.yahoo.com' result = urlutils.urlsplit(url) self.assertEquals(result.scheme, 'http')
def test_urlunsplit(self): url = "http://www.yahoo.com" result = urlutils.urlunsplit(urlutils.urlsplit(url)) self.assertEqual(result, 'http://www.yahoo.com')
def test_urlsplit(self): url = 'http://www.yahoo.com' result = urlutils.urlsplit(url) self.assertEqual(result.scheme, 'http')