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

Provide pytest fixture for input faker.

parent 70e9285d
No related branches found
No related tags found
No related merge requests found
......@@ -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: ")
......
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