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

Function test_to_unicode

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

Source from the content-addressed store, hash-verified

47
48
49def test_to_unicode():
50 assert strings.to_unicode(u'юникод') == u'юникод'
51 assert strings.to_unicode('str') == u'str'
52 assert strings.to_unicode(u'строка'.encode('utf-8')) == u'строка'
53 assert strings.to_unicode(u'строка'.encode('cp1251'), 'cp1251') == u'строка'
54 if six.PY2: # __str__ should return str not bytes in Python3
55 assert strings.to_unicode(Convertible()) == Convertible.text
56 assert strings.to_unicode(ConvertibleToUnicodeOnly()) == Convertible.text
57 with pytest.raises(UnicodeDecodeError):
58 strings.to_unicode(ConvertibleToStrOnly())
59 with pytest.raises(UnicodeDecodeError):
60 strings.to_unicode(NonConvertible())
61
62
63def test_to_unicode_errors_replace():

Callers

nothing calls this directly

Calls 5

ConvertibleClass · 0.85
NonConvertibleClass · 0.85
encodeMethod · 0.45

Tested by

no test coverage detected