Files
micropython/tests/extmod/random_extra_float.py
Damien George e4d556b149 tests/extmod/random_extra_float.py: Skip when funcs not available.
This test was factored out from `random_extra.py` back in commit
6572029dc0, and the skip logic copied from
that file.  But the skip logic needs to test that the `random` and
`uniform` functions exist, not `randint`.

This commit fixes that skip logic.

Signed-off-by: Damien George <damien@micropython.org>
2025-06-12 21:45:40 +10:00

18 lines
358 B
Python

try:
import random
random.random
except (ImportError, AttributeError):
print("SKIP")
raise SystemExit
print("random")
for i in range(50):
assert 0 <= random.random() < 1
print("uniform")
for i in range(50):
assert 0 <= random.uniform(0, 4) <= 4
assert 2 <= random.uniform(2, 6) <= 6
assert -2 <= random.uniform(-2, 2) <= 2