def test_sim_random_is_deterministic():
    rnd1 = DefaultSimRandom(42)
    values1 = [rnd1.integer(10, 50) for _ in range(100)]

    rnd2 = DefaultSimRandom(42)
    values2 = [rnd2.integer(10, 50) for _ in range(100)]

    assert values1 == values2
Example #2
0
def test_sim_random_is_repeatable_between_runs():
    rnd = DefaultSimRandom()
    values = [rnd.integer(0, 100) for _ in range(5)]
    assert values == [49, 97, 53, 5, 33]
Example #3
0
def test_sim_random_shuffles():
    rnd = DefaultSimRandom()
    values = [rnd.integer(10, 50) for _ in range(100)]
    shuffled = rnd.shuffle(values)
    assert values != shuffled
Example #4
0
def test_sim_random_generates_integers_in_required_range():
    rnd = DefaultSimRandom()
    values = [rnd.integer(10, 50) for _ in range(100)]
    assert all(10 <= v <= 50 for v in values)
Example #5
0
def test_sim_random_generates_strings_of_requried_length():
    rnd = DefaultSimRandom()
    lengths = [rnd.integer(0, 10) for _ in range(100)]
    values = [(rnd.string(_len), _len) for _len in lengths]
    assert all(len(s) == l for s, l in values)