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 2
2
3
3
import sys
4
4
from future .tests .base import unittest
5
+ from future .standard_library import install_aliases
6
+
5
7
6
8
class ImportUrllibTest (unittest .TestCase ):
7
9
def test_urllib (self ):
@@ -16,6 +18,27 @@ def test_urllib(self):
16
18
import urllib .response
17
19
self .assertEqual (orig_file , urllib .__file__ )
18
20
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
+
19
42
20
43
if __name__ == '__main__' :
21
44
unittest .main ()
You can’t perform that action at this time.
0 commit comments