micropython/tests/basics/weakref_ref_basic.py
Damien George c91d09a00d tests/basics: Add tests for weakref.ref and weakref.finalize.
Signed-off-by: Damien George <damien@micropython.org>
2026-03-22 23:06:01 +11:00

15 lines
339 B
Python

# Test weakref.ref() functionality that doesn't require gc.collect().
try:
import weakref
except ImportError:
print("SKIP")
raise SystemExit
# Cannot reference non-heap objects.
for value in (None, False, True, Ellipsis, 0, "", ()):
try:
weakref.ref(value)
except TypeError:
print(value, "TypeError")