Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
diceware-debian
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
drebs
diceware-debian
Commits
d3806f1f
Commit
d3806f1f
authored
8 years ago
by
ulif
Browse files
Options
Downloads
Patches
Plain Diff
Add choice test for overlong sequences.
parent
27e17827
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_random_sources.py
+13
-1
13 additions, 1 deletion
tests/test_random_sources.py
with
13 additions
and
1 deletion
tests/test_random_sources.py
+
13
−
1
View file @
d3806f1f
...
...
@@ -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
"
])
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment