Files
micropython/tests/extmod/binascii_unhexlify.py
Damien George c83e907d9d tests/extmod: Skip binascii tests when hexlify/unhexlify don't exist.
These functions are only available when `MICROPY_PY_BUILTINS_BYTES_HEX` is
enabled.

Signed-off-by: Damien George <damien@micropython.org>
2025-04-24 22:06:11 +10:00

24 lines
421 B
Python

try:
from binascii import unhexlify
except ImportError:
print("SKIP")
raise SystemExit
for x in (
b"0001020304050607",
b"08090a0b0c0d0e0f",
b"7f80ff",
b"313233344142434461626364",
):
print(unhexlify(x))
try:
a = unhexlify(b"0") # odd buffer length
except ValueError:
print("ValueError")
try:
a = unhexlify(b"gg") # digit not hex
except ValueError:
print("ValueError")