Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(69988)

Side by Side Diff: Lib/test/test_urllib.py

Issue 16285: Update urllib quoting to RFC 3986
Patch Set: Created 5 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Lib/urllib/parse.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """Regresssion tests for urllib""" 1 """Regresssion tests for urllib"""
2 2
3 import urllib.parse 3 import urllib.parse
4 import urllib.request 4 import urllib.request
5 import urllib.error 5 import urllib.error
6 import http.client 6 import http.client
7 import email.message 7 import email.message
8 import io 8 import io
9 import unittest 9 import unittest
10 from test import support 10 from test import support
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 Unwise : "{}|\^[]`" 622 Unwise : "{}|\^[]`"
623 Must be escaped 623 Must be escaped
624 624
625 """ 625 """
626 626
627 def test_never_quote(self): 627 def test_never_quote(self):
628 # Make sure quote() does not quote letters, digits, and "_,.-" 628 # Make sure quote() does not quote letters, digits, and "_,.-"
629 do_not_quote = '' .join(["ABCDEFGHIJKLMNOPQRSTUVWXYZ", 629 do_not_quote = '' .join(["ABCDEFGHIJKLMNOPQRSTUVWXYZ",
630 "abcdefghijklmnopqrstuvwxyz", 630 "abcdefghijklmnopqrstuvwxyz",
631 "0123456789", 631 "0123456789",
632 "_.-"]) 632 "_.-~"])
633 result = urllib.parse.quote(do_not_quote) 633 result = urllib.parse.quote(do_not_quote)
634 self.assertEqual(do_not_quote, result, 634 self.assertEqual(do_not_quote, result,
635 "using quote(): %r != %r" % (do_not_quote, result)) 635 "using quote(): %r != %r" % (do_not_quote, result))
636 result = urllib.parse.quote_plus(do_not_quote) 636 result = urllib.parse.quote_plus(do_not_quote)
637 self.assertEqual(do_not_quote, result, 637 self.assertEqual(do_not_quote, result,
638 "using quote_plus(): %r != %r" % (do_not_quote, result)) 638 "using quote_plus(): %r != %r" % (do_not_quote, result))
639 639
640 def test_default_safe(self): 640 def test_default_safe(self):
641 # Test '/' is default value for 'safe' parameter 641 # Test '/' is default value for 'safe' parameter
642 self.assertEqual(urllib.parse.quote.__defaults__[0], '/') 642 self.assertEqual(urllib.parse.quote.__defaults__[0], '/')
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
1442 1442
1443 def test_roundtrip_pathname2url(self): 1443 def test_roundtrip_pathname2url(self):
1444 list_of_paths = ['///C:', 1444 list_of_paths = ['///C:',
1445 '/////folder/test/', 1445 '/////folder/test/',
1446 '///C:/foo/bar/spam.foo'] 1446 '///C:/foo/bar/spam.foo']
1447 for path in list_of_paths: 1447 for path in list_of_paths:
1448 self.assertEqual(pathname2url(url2pathname(path)), path) 1448 self.assertEqual(pathname2url(url2pathname(path)), path)
1449 1449
1450 if __name__ == '__main__': 1450 if __name__ == '__main__':
1451 unittest.main() 1451 unittest.main()
OLDNEW
« no previous file with comments | « no previous file | Lib/urllib/parse.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+