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

Give a more meaningful msg if entropy is reduced.

parent 19cc3046
No related branches found
No related tags found
No related merge requests found
......@@ -137,7 +137,11 @@ class RealDiceRandomSource(object):
raise ValueError(
"Must provide at least %s items" % self.dice_sides)
if (self.dice_sides ** num_rolls) < len(sequence):
print("Warning: entropy is reduced!")
print(
"Warning: entropy is reduced! Using only first %s of %s "
"words/items of your wordlist." % (
self.dice_sides ** num_rolls, len(sequence))
)
print(
"Please roll %s dice (or a single dice %s times)." % (
num_rolls, num_rolls))
......
......@@ -196,6 +196,7 @@ class TestRealDiceRandomSource(object):
assert picked == 1
out, err = capsys.readouterr()
assert "entropy is reduced" in out
assert "Using only first 6 of 7 words" in out
assert err == ""
def test_no_hint_if_entropy_is_not_decreased(self, monkeypatch, capsys):
......
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