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 )
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") )
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') )
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") )
def test_nonascii_bytes(self): ''' Test possibly_decode() with unicode bytes input ''' self.assertEqual( utils_path.possibly_decode('cio\xc3\xa8', 'utf-8'), six.u("cio\xe8") )