()
| 66 | |
| 67 | |
| 68 | def 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 | |
| 82 | def test_to_str_errors_replace(): |
nothing calls this directly
no test coverage detected