File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 22
33import sys
44from future .tests .base import unittest
5+ from future .standard_library import install_aliases
6+
57
68class ImportUrllibTest (unittest .TestCase ):
79 def test_urllib (self ):
@@ -16,6 +18,27 @@ def test_urllib(self):
1618 import urllib .response
1719 self .assertEqual (orig_file , urllib .__file__ )
1820
21+ def test_issue_158 (self ):
22+ """
23+ CherryPy conditional import in _cpcompat.py: issue 158
24+ """
25+ install_aliases ()
26+ try :
27+ from urllib .parse import unquote as parse_unquote
28+
29+ def unquote_qs (atom , encoding , errors = 'strict' ):
30+ return parse_unquote (
31+ atom .replace ('+' , ' ' ),
32+ encoding = encoding ,
33+ errors = errors )
34+ except ImportError :
35+ from urllib import unquote as parse_unquote
36+
37+ def unquote_qs (atom , encoding , errors = 'strict' ):
38+ return parse_unquote (atom .replace ('+' , ' ' )).decode (encoding , errors )
39+ self .assertEqual (unquote_qs ('/%7Econnolly/' , 'utf-8' ),
40+ '/~connolly/' )
41+
1942
2043if __name__ == '__main__' :
2144 unittest .main ()
You can’t perform that action at this time.
0 commit comments