mirror of
https://github.com/micropython/micropython.git
synced 2025-07-21 21:11:12 +02:00
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>
18 lines
358 B
Python
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
|