示例#1
0
文件: tests.py 项目: jparise/yuri
    def test_basic_encoding(self):
        should_encode = [chr(num) for num in range(32)] # For 0x00 - 0x1F
        should_encode.append('<>#%"{}|\^[]`')
        should_encode.append(chr(127)) # For 0x7F
        should_encode = ''.join(should_encode)

        for char in should_encode:
            result = yuri.encode(char, query=False)
            self.assertEqual(hexed(char), result)
            result = yuri.encode(char, query=True)
            self.assertEqual(hexed(char), result)

        del should_encode
        partial_encode = 'ab[]cd'
        expected = 'ab%5B%5Dcd'
        result = yuri.encode(partial_encode, query=True)
        self.assertEqual(expected, result)
        result = yuri.encode(partial_encode, query=False)
        self.assertEqual(expected, result)
        self.assertRaises(TypeError, yuri.encode, None)
示例#2
0
文件: tests.py 项目: jparise/yuri
 def test_path_encoding(self):
     self.assertEqual(yuri.encode('/', query=False), '/')
     self.assertEqual(yuri.encode(' ', query=False), '%20')
示例#3
0
文件: tests.py 项目: jparise/yuri
 def test_query_encoding(self):
     self.assertEqual(yuri.encode('/', query=True), '%2F')
     self.assertEqual(yuri.encode(' ', query=True), '+')
示例#4
0
文件: tests.py 项目: jparise/yuri
    def test_unreserved_characters(self):
        result = yuri.encode(yuri.unreserved_characters, query=False)
        self.assertEqual(result, yuri.unreserved_characters)

        result = yuri.encode(yuri.unreserved_characters, query=True)
        self.assertEqual(result, yuri.unreserved_characters)