Files
RustPython/extra_tests/snippets/builtin_str_encode.py
Rex Ledesma 4e2e0b41c6 chore: add ruff format --check (#5774)
* chore: add `ruff format --check`

* fix tests
2025-05-12 14:20:01 +09:00

23 lines
586 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from testutils import assert_raises
try:
b" \xff".decode("ascii")
except UnicodeDecodeError as e:
assert e.start == 3
assert e.end == 4
else:
assert False, "should have thrown UnicodeDecodeError"
assert_raises(UnicodeEncodeError, "¿como estás?".encode, "ascii")
def round_trip(s, encoding="utf-8"):
encoded = s.encode(encoding)
decoded = encoded.decode(encoding)
assert s == decoded
round_trip("πŸ‘Ίβ™¦ πšΕžΔ‘Ζ’ β˜†β˜")
round_trip("☒🐣 α–‡π“€π•ŠΡ‚β“Ÿπ•π•₯卄σ𝔫 β™¬πŸ‘£")
round_trip("πŸ’€πŸ‘Œ ק𝔂tβ„β“žπ“· οΌ“ πŸ”₯πŸ‘€")