circuitpython/tests/extmod/urandom_seed_default.py
2023-08-22 12:57:47 -04:00

28 lines
505 B
Python

# test urandom.seed() without any arguments
try:
import random
except ImportError:
print("SKIP")
raise SystemExit
try:
random.seed()
except ValueError:
# no default seed on this platform
print("SKIP")
raise SystemExit
def rng_seq():
return [random.getrandbits(16) for _ in range(10)]
# seed with default and check that doesn't produce the same RNG sequence
random.seed()
seq = rng_seq()
random.seed()
print(seq == rng_seq())
random.seed(None)
print(seq == rng_seq())