Ejemplo n.º 1
0
 def test_decode_failure(self):
     ''' Make sure that possibly_decode() does not decode
         an invalid UTF-8 string '''
     self.assertEqual(
         utils_path.possibly_decode(six.b("\xc2b7"), 'utf-8'),
         None
     )
Ejemplo n.º 2
0
 def test_nonascii_str(self):
     ''' Test possibly_decode() with unicode string input '''
     self.assertEqual(
         utils_path.possibly_decode(six.u("cio\xe8"), 'utf-8'),
         six.u("cio\xe8")
     )
Ejemplo n.º 3
0
 def test_ascii_str(self):
     ''' Test possibly_decode() with ascii string input '''
     self.assertEqual(
         utils_path.possibly_decode(six.u("abc"), 'utf-8'),
         six.u("abc")
     )
Ejemplo n.º 4
0
 def test_nonascii_bytes(self):
     ''' Test possibly_decode() with unicode bytes input '''
     self.assertEqual(
         utils_path.possibly_decode(six.b('cio\xc3\xa8'), 'utf-8'),
         six.u("cio\xe8")
     )
Ejemplo n.º 5
0
 def test_ascii_bytes(self):
     ''' Test possibly_decode() with ascii bytes input '''
     self.assertEqual(
         utils_path.possibly_decode(six.b('abc'), 'utf-8'),
         six.u('abc')
     )
Ejemplo n.º 6
0
 def test_decode_failure(self):
     ''' Make sure that possibly_decode() does not decode
         an invalid UTF-8 string '''
     self.assertEqual(utils_path.possibly_decode(six.b("\xc2b7"), 'utf-8'),
                      None)
Ejemplo n.º 7
0
 def test_ascii_str(self):
     ''' Test possibly_decode() with ascii string input '''
     self.assertEqual(utils_path.possibly_decode(six.u("abc"), 'utf-8'),
                      six.u("abc"))
Ejemplo n.º 8
0
 def test_nonascii_str(self):
     ''' Test possibly_decode() with unicode string input '''
     self.assertEqual(utils_path.possibly_decode(six.u("cio\xe8"), 'utf-8'),
                      six.u("cio\xe8"))
Ejemplo n.º 9
0
 def test_ascii_bytes(self):
     ''' Test possibly_decode() with ascii bytes input '''
     self.assertEqual(utils_path.possibly_decode(six.b('abc'), 'utf-8'),
                      six.u('abc'))
Ejemplo n.º 10
0
 def test_nonascii_bytes(self):
     ''' Test possibly_decode() with unicode bytes input '''
     self.assertEqual(
         utils_path.possibly_decode(six.b('cio\xc3\xa8'), 'utf-8'),
         six.u("cio\xe8"))