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

Function test_to_str

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

Source from the content-addressed store, hash-verified

66
67
68def test_to_str():
69 assert strings.to_str('str') == 'str' if six.PY2 else b'str'
70 assert strings.to_str(u'unicode') == 'unicode' if six.PY2 else b'unicode'
71 assert strings.to_str(u'юникод') == u'юникод'.encode('utf-8')
72 assert strings.to_str(u'юникод', 'cp1251') == u'юникод'.encode('cp1251')
73 if six.PY2:
74 assert strings.to_str(Convertible()) == Convertible.text_utf8
75 with pytest.raises(UnicodeEncodeError):
76 strings.to_str(ConvertibleToUnicodeOnly())
77 assert strings.to_str(ConvertibleToStrOnly()) == Convertible.text_utf8
78 with pytest.raises(UnicodeEncodeError):
79 strings.to_str(NonConvertible())
80
81
82def test_to_str_errors_replace():

Callers

nothing calls this directly

Calls 5

ConvertibleClass · 0.85
NonConvertibleClass · 0.85
encodeMethod · 0.45

Tested by

no test coverage detected