Example #1
0
 def test_uriencode(self):
     cases = [
         ('%', '%25'),
         ('あい', '%E3%81%82%E3%81%84'),
         ('あ い', '%E3%81%82%20%E3%81%84'),
     ]
     for input, output in cases:
         self.assertEqual(uriencode(input), output)
Example #2
0
def encode_path(path):
    splited = urilib.urisplit(path)
    epath = urilib.uriencode(splited.path, safe='/$*?=&;@,#')
    if splited.query:
        query = urilib.uriencode_plus(splited.query, safe='/$*?=&;@,#')
        path = epath + '?' + query
    else:
        if path[-1] == '?':
            path = epath + '?'
        else:
            path = epath
    return path
Example #3
0
 def test_encode_bytes(self):
     cases = [
         (b'\xf6lk\xfcrbis', b'%F6lk%FCrbis')
     ]
     for input, output in cases:
         self.assertEqual(uriencode(input), output)
Example #4
0
 def check(self, decoded, encoded, safe='', encoding='utf-8'):
     self.assertEqual(uriencode(decoded, safe, encoding), encoded)
     self.assertEqual(uridecode(encoded, encoding), decoded)