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

Add test to ensure `dice_sides` is really used.

We have to make sure, that `dice_sides` is really used when picking
random values.
parent 9b56a705
No related branches found
No related tags found
No related merge requests found
...@@ -282,3 +282,13 @@ class TestRealDiceRandomSource(object): ...@@ -282,3 +282,13 @@ class TestRealDiceRandomSource(object):
out, err = capsys.readouterr() out, err = capsys.readouterr()
assert "roll 2 dice" in out assert "roll 2 dice" in out
assert picked == 1 assert picked == 1
def test_dice_sides_respected(self, capsys, monkeypatch):
# we use the number of dice sides given by options dict.
self.fake_input_values(["1", "2"], monkeypatch)
src = RealDiceRandomSource(dict(dice_sides=2)) # a coin
picked = src.choice(['a', 'b', 'c', 'd'])
out, err = capsys.readouterr()
# must throw a coin 2 times to pick one out of 4 items
assert "Please roll 2 dice" in out
assert picked == 'b'
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