summaryrefslogtreecommitdiff
path: root/tests/extmod/urandom_seed_default.py
blob: a032b9362b701245cccf4fb62f7bc5e367eb2845 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# test urandom.seed() without any arguments

try:
    import urandom as random
except ImportError:
    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())