MCPcopy Create free account
hub / github.com/catboost/catboost / test_to_str_transcode

Function test_to_str_transcode

library/python/strings/ut/test_strings.py:87–101  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

85
86
87def test_to_str_transcode():
88 assert strings.to_str('str', from_enc='ascii') == 'str' if six.PY2 else b'str'
89 assert strings.to_str('str', from_enc='utf-8') == 'str' if six.PY2 else b'str'
90
91 assert strings.to_str(u'юникод'.encode('utf-8'), from_enc='utf-8') == u'юникод'.encode('utf-8')
92 assert strings.to_str(u'юникод'.encode('utf-8'), to_enc='utf-8', from_enc='utf-8') == u'юникод'.encode('utf-8')
93 assert strings.to_str(u'юникод'.encode('utf-8'), to_enc='cp1251', from_enc='utf-8') == u'юникод'.encode('cp1251')
94
95 assert strings.to_str(u'юникод'.encode('cp1251'), from_enc='cp1251') == u'юникод'.encode('utf-8')
96 assert strings.to_str(u'юникод'.encode('cp1251'), to_enc='cp1251', from_enc='cp1251') == u'юникод'.encode('cp1251')
97 assert strings.to_str(u'юникод'.encode('cp1251'), to_enc='utf-8', from_enc='cp1251') == u'юникод'.encode('utf-8')
98
99 assert strings.to_str(u'юникод'.encode('koi8-r'), from_enc='koi8-r') == u'юникод'.encode('utf-8')
100 assert strings.to_str(u'юникод'.encode('koi8-r'), to_enc='koi8-r', from_enc='koi8-r') == u'юникод'.encode('koi8-r')
101 assert strings.to_str(u'юникод'.encode('koi8-r'), to_enc='cp1251', from_enc='koi8-r') == u'юникод'.encode('cp1251')
102
103
104def test_to_str_transcode_wrong():

Callers

nothing calls this directly

Calls 1

encodeMethod · 0.45

Tested by

no test coverage detected