forked from Rust-related/RustPython
21 lines
584 B
Python
21 lines
584 B
Python
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 estaΜ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ββπ· οΌ π₯π€")
|