Kaydet (Commit) 578617ad authored tarafından Senthil Kumaran's avatar Senthil Kumaran

merge from 3.2 - Fix closes issue12581 - Increase the urllib.parse test coverage…

merge from 3.2 - Fix closes issue12581 - Increase the urllib.parse test coverage (cases applicable to 2.7). Patch by Petter Haggholm.
üst f364ce24
...@@ -82,7 +82,12 @@ class UrlParseTestCase(unittest.TestCase): ...@@ -82,7 +82,12 @@ class UrlParseTestCase(unittest.TestCase):
def test_qsl(self): def test_qsl(self):
for orig, expect in parse_qsl_test_cases: for orig, expect in parse_qsl_test_cases:
result = urlparse.parse_qsl(orig, keep_blank_values=True) result = urlparse.parse_qsl(orig, keep_blank_values=True)
self.assertEqual(result, expect, "Error parsing %s" % repr(orig)) self.assertEqual(result, expect, "Error parsing %r" % orig)
expect_without_blanks = [v for v in expect if len(v[1])]
result = urlparse.parse_qsl(orig, keep_blank_values=False)
self.assertEqual(result, expect_without_blanks,
"Error parsing %r" % orig)
def test_roundtrips(self): def test_roundtrips(self):
testcases = [ testcases = [
...@@ -331,6 +336,9 @@ class UrlParseTestCase(unittest.TestCase): ...@@ -331,6 +336,9 @@ class UrlParseTestCase(unittest.TestCase):
self.checkJoin(SIMPLE_BASE, 'http:?y','http://a/b/c/d?y') self.checkJoin(SIMPLE_BASE, 'http:?y','http://a/b/c/d?y')
self.checkJoin(SIMPLE_BASE, 'http:g?y','http://a/b/c/g?y') self.checkJoin(SIMPLE_BASE, 'http:g?y','http://a/b/c/g?y')
self.checkJoin(SIMPLE_BASE, 'http:g?y/./x','http://a/b/c/g?y/./x') self.checkJoin(SIMPLE_BASE, 'http:g?y/./x','http://a/b/c/g?y/./x')
self.checkJoin('http:///', '..','http:///')
self.checkJoin('', 'http://a/b/c/g?y/./x','http://a/b/c/g?y/./x')
self.checkJoin('', 'http://a/./g', 'http://a/./g')
def test_RFC2732(self): def test_RFC2732(self):
for url, hostname, port in [ for url, hostname, port in [
...@@ -505,7 +513,6 @@ class UrlParseTestCase(unittest.TestCase): ...@@ -505,7 +513,6 @@ class UrlParseTestCase(unittest.TestCase):
self.assertEqual(urlparse.urlparse("http://www.python.org:80"), self.assertEqual(urlparse.urlparse("http://www.python.org:80"),
('http','www.python.org:80','','','','')) ('http','www.python.org:80','','','',''))
def test_main(): def test_main():
test_support.run_unittest(UrlParseTestCase) test_support.run_unittest(UrlParseTestCase)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment