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
1e1ce2b0
Commit
1e1ce2b0
authored
8 years ago
by
dwcoder
Browse files
Options
Downloads
Patches
Plain Diff
Write unit tests for the new pre_check function
It is passing and doing as expected.
parent
36089112
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
+14
-0
14 additions, 0 deletions
tests/test_random_sources.py
with
14 additions
and
0 deletions
tests/test_random_sources.py
+
14
−
0
View file @
1e1ce2b0
...
...
@@ -263,3 +263,17 @@ class TestRealDiceRandomSource(object):
src
.
pre_check
(
5
,
[
'
doesntmatter
'
])
out
,
err
=
capsys
.
readouterr
()
assert
"
Please roll 5 dice (or a single dice 5 times).
"
in
out
def
test_sequence_less_than_dice_sides
(
self
,
capsys
):
# Test to see whether we can use a n-sided die to choose from a sequence with less than n items
src
=
RealDiceRandomSource
(
None
)
# If we give a value of num_rolls < 1,
# the pre_check should fix the number of rolls
# and notify us to use the modulo
num_rolls
,
usemodulo
=
src
.
pre_check
(
0.5
,
[
'
abc
'
])
assert
num_rolls
>
1
assert
usemodulo
# But if we give num_rolls > 1, it should do no such thing:
num_rolls
,
usemodulo
=
src
.
pre_check
(
5
,
range
(
1
,
6
**
5
))
assert
num_rolls
==
5
assert
not
usemodulo
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