Пример #1
0
 def test_decode_utf8_error_leading_byte(self):
     b = BitList('10000011')
     with self.assertRaises(DecodeError):
         b.decode('utf-8')
Пример #2
0
 def test_decode_invalid_encoding_name(self):
     b = BitList('1111000010011111100110001000001')
     with self.assertRaises(ValueError):
         b.decode('foo')
Пример #3
0
 def test_decode_utf8_default(self):
     b = BitList('01000011')
     self.assertEqual(b.decode(), 'C')
Пример #4
0
 def test_decode_utf8_error_continuation_byte(self):
     b = BitList('11110000000111111001100010000010')
     with self.assertRaises(DecodeError):
         b.decode('utf-8')
Пример #5
0
 def test_decode_utf8_3_bytes(self):
     b = BitList('111000101000001010101100')
     self.assertEqual(b.decode('utf-8'), '€')
Пример #6
0
 def test_decode_utf8_1_byte(self):
     b = BitList('01000001')
     self.assertEqual(b.decode('utf-8'), 'A')
Пример #7
0
 def test_decode_utf8_4_bytes(self):
     b = BitList('11110000100111111001100010000010')
     self.assertEqual(b.decode('utf-8'), '😂')
Пример #8
0
 def test_decode_utf8_4_bytes_multiple_chars(self):
     b = BitList('11110000100111111001100010000010111000101000001010101100')
     self.assertEqual(b.decode('utf-8'), '😂€')
Пример #9
0
 def test_decode_ascii_multiple_chars(self):
     b = BitList('10000011011011')
     self.assertEqual(b.decode('us-ascii'), 'A[')
Пример #10
0
 def test_decode_ascii_bracket(self):
     b = BitList('1011011')
     self.assertEqual(b.decode('us-ascii'), '[')
Пример #11
0
 def test_decode_ascii_A(self):
     b = BitList('1000001')
     self.assertEqual(b.decode('us-ascii'), 'A')