コード例 #1
0
ファイル: web_test.py プロジェクト: wmark/anzu
 def decode_argument(self, value, name=None):
     assert type(value) == bytes_type, repr(value)
     # use self.request.arguments directly to avoid recursion
     if 'encoding' in self.request.arguments:
         return value.decode(to_unicode(self.request.arguments['encoding'][0]))
     else:
         return value
コード例 #2
0
ファイル: web_test.py プロジェクト: genelee/anzu
 def decode_argument(self, value, name=None):
     assert type(value) == bytes_type, repr(value)
     # use self.request.arguments directly to avoid recursion
     if 'encoding' in self.request.arguments:
         return value.decode(
             to_unicode(self.request.arguments['encoding'][0]))
     else:
         return value
コード例 #3
0
ファイル: escape_test.py プロジェクト: wmark/anzu
 def test_url_unescape(self):
     tests = [
         ('%C3%A9', u'\u00e9', 'utf8'),
         ('%C3%A9', u'\u00c3\u00a9', 'latin1'),
         ('%C3%A9', utf8(u'\u00e9'), None),
         ]
     for escaped, unescaped, encoding in tests:
         # input strings to url_unescape should only contain ascii
         # characters, but make sure the function accepts both byte
         # and unicode strings.
         self.assertEqual(url_unescape(to_unicode(escaped), encoding), unescaped)
         self.assertEqual(url_unescape(utf8(escaped), encoding), unescaped)
コード例 #4
0
ファイル: escape_test.py プロジェクト: genelee/anzu
 def test_url_unescape(self):
     tests = [
         ('%C3%A9', u'\u00e9', 'utf8'),
         ('%C3%A9', u'\u00c3\u00a9', 'latin1'),
         ('%C3%A9', utf8(u'\u00e9'), None),
     ]
     for escaped, unescaped, encoding in tests:
         # input strings to url_unescape should only contain ascii
         # characters, but make sure the function accepts both byte
         # and unicode strings.
         self.assertEqual(url_unescape(to_unicode(escaped), encoding),
                          unescaped)
         self.assertEqual(url_unescape(utf8(escaped), encoding), unescaped)