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
4b51013a
Commit
4b51013a
authored
8 years ago
by
ulif
Browse files
Options
Downloads
Patches
Plain Diff
Provide pytest fixture for input faker.
parent
70e9285d
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
+9
-2
9 additions, 2 deletions
tests/test_random_sources.py
with
9 additions
and
2 deletions
tests/test_random_sources.py
+
9
−
2
View file @
4b51013a
...
...
@@ -75,14 +75,21 @@ def fake_input_values(values, patch):
return
input_mock
@pytest.fixture
(
scope
=
"
function
"
)
def
fake_input_handler
(
request
,
monkeypatch
):
def
handler
(
values
):
return
fake_input_values
(
values
,
monkeypatch
)
return
handler
class
TestRealDiceRandomSource
(
object
):
def
test_raw_input_patch_works
(
self
,
monkeypatch
,
capsys
):
def
test_raw_input_patch_works
(
self
,
capsys
,
fake_input_handler
):
# make sure our fake input works. We try to fake input ('foo',
# 'bar') and make sure that output is captured.
# This test is just a hint, how input could be faked in real tests.
# It can (and should) be removed if not needed any more.
fake_input_
values
([
"
foo
"
,
"
bar
"
]
,
monkeypatch
)
fake_input_
handler
([
"
foo
"
,
"
bar
"
])
# late import, because we need the patched version
from
diceware.random_sources
import
input_func
result1
=
input_func
(
"
Enter some values:
"
)
...
...
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