File: test-set_prng_seed.py

package info (click to toggle)
libfiu 1.2-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 768 kB
  • sloc: ansic: 2,633; python: 973; makefile: 599; sh: 309
file content (23 lines) | stat: -rw-r--r-- 488 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""
Test that we get reproducible results with manually set PRNG seeds.
"""

import fiu


fiu.set_prng_seed(1234)
fiu.enable_random("p1", probability=0.5)
result = {True: 0, False: 0}
for i in range(1000):
    result[fiu.fail("p1")] += 1

assert result == {False: 516, True: 484}, result


fiu.set_prng_seed(4321)
fiu.enable_random("p1", probability=0.5)
result = {True: 0, False: 0}
for i in range(1000):
    result[fiu.fail("p1")] += 1

assert result == {False: 495, True: 505}, result