Skip to content
Snippets Groups Projects
Commit d3806f1f authored by ulif's avatar ulif
Browse files

Add choice test for overlong sequences.

parent 27e17827
No related branches found
No related tags found
No related merge requests found
......@@ -272,7 +272,7 @@ class TestRealDiceRandomSource(object):
for x in range(16):
picked = src.choice([1, 2, 3])
dist[picked - 1] += 1
assert dist == [6, 5, 5]
assert dist == [6, 5, 5] # this is not fair, is it?
def test_choice_distributes_equally(self, fake_input):
# we distribute nearly equally over sequences sized
......@@ -286,6 +286,18 @@ class TestRealDiceRandomSource(object):
dist[picked - 1] += 1
assert dist == [1, 1, 1]
def test_choice_distributes_equally_on_long_seq(self, fake_input):
# we distribute nearly equally over sequences longer than
# dice_sides**n
src = RealDiceRandomSource(None)
src.dice_sides = 2
dist = [0, 0, 0]
fake_input(["1", "1", "1", "2", "2", "1", "2", "2"])
for x in range(8):
picked = src.choice([1, 2, 3])
dist[picked - 1] += 1
assert dist == [4, 4, 0]
def test_choice_respects_dice_sides(self, capsys, fake_input):
# we use the number of dice sides given by options dict.
fake_input(["1", "2"])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment