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
c36c7d0d
Commit
c36c7d0d
authored
9 years ago
by
ulif
Browse files
Options
Downloads
Patches
Plain Diff
Regression tests for input range.
parent
e60dbb3c
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 @
c36c7d0d
...
@@ -211,6 +211,20 @@ class TestRealDiceRandomSource(object):
...
@@ -211,6 +211,20 @@ class TestRealDiceRandomSource(object):
with
pytest
.
raises
(
ValueError
):
with
pytest
.
raises
(
ValueError
):
assert
src
.
choice
([
1
,
2
,
3
,
4
,
5
])
# list len < 6
assert
src
.
choice
([
1
,
2
,
3
,
4
,
5
])
# list len < 6
def
test_choice_input_lower_value_borders
(
self
,
monkeypatch
):
# choice() does not accept "0" but it accepts "1"
self
.
fake_input_values
([
"
0
"
,
"
1
"
],
monkeypatch
)
src
=
RealDiceRandomSource
(
None
)
sequence
=
(
1
,
2
,
3
,
4
,
5
,
6
)
assert
src
.
choice
(
sequence
)
==
1
def
test_choice_input_upper_value_borders
(
self
,
monkeypatch
):
# choice() does not accept "7" but it accepts "6"
self
.
fake_input_values
([
"
7
"
,
"
6
"
],
monkeypatch
)
src
=
RealDiceRandomSource
(
None
)
sequence
=
(
1
,
2
,
3
,
4
,
5
,
6
)
assert
src
.
choice
(
sequence
)
==
6
def
test_pre_check_no_rolls_cause_exception
(
self
):
def
test_pre_check_no_rolls_cause_exception
(
self
):
# we cannot pick zero items of a sequence
# we cannot pick zero items of a sequence
src
=
RealDiceRandomSource
(
None
)
src
=
RealDiceRandomSource
(
None
)
...
...
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