def one_try(self, url, scheme='', host='', path='', query='', fragment='', userinfo='', port='', invalid=None, urlsplit=True): orih_url = url url = URL(url) splitted = (scheme, userinfo, host, port, path, query, fragment) self.assertEqual(url._data, splitted) self.assertEqual(URL(None, *splitted)._data, splitted) self.assertEqual(URL(None, *url._data)._data, splitted) if invalid: self.assertRaises(invalid, url.validate) else: url.validate() if urlsplit and '-v' in sys.argv: splitted = (scheme, url.authority, path, query, fragment) split_result = self.split(orih_url) if split_result != splitted: print('\n urllib issue:', orih_url, self.split(orih_url)) elif (split_result.hostname or '') != host: print('\n urllib issue:', orih_url, 'host is:', split_result.hostname, 'host should:', host)