()
| 9 | |
| 10 | |
| 11 | def test_to_bytes(): |
| 12 | # type: () -> None |
| 13 | assert isinstance(to_bytes(""), bytes) |
| 14 | assert isinstance(to_bytes("abc"), bytes) |
| 15 | assert isinstance(to_bytes(b"abc"), bytes) |
| 16 | assert isinstance(to_bytes(u"abc"), bytes) |
| 17 | assert isinstance(to_bytes(b"abc".decode("latin-1"), encoding=u"utf-8"), bytes) |
| 18 | |
| 19 | for bad_value in (123, None): |
| 20 | with pytest.raises(ValueError): |
| 21 | to_bytes(bad_value) # type: ignore[type-var] |
| 22 | |
| 23 | |
| 24 | def test_to_unicode(): |