fix first test (inject command fixture to request)

This commit is contained in:
Jonathan Wren 2023-02-04 11:07:36 -08:00
parent 58af780f50
commit a468510bcc
No known key found for this signature in database
2 changed files with 15 additions and 1 deletions

View file

@ -201,6 +201,16 @@ def input_method():
return "" return ""
@fixture
def all_input():
return ""
@fixture
def command():
return ""
@fixture @fixture
def cache_dir(): def cache_dir():
return {"exists": False, "path": ""} return {"exists": False, "path": ""}

View file

@ -7,6 +7,7 @@ from contextlib import ExitStack
from pytest_bdd import when from pytest_bdd import when
from pytest_bdd.parsers import parse from pytest_bdd.parsers import parse
from pytest_bdd.parsers import re from pytest_bdd.parsers import re
from pytest_bdd.steps import inject_fixture
from jrnl.main import run from jrnl.main import run
@ -31,11 +32,14 @@ all_input = '("(?P<all_input>[^"]*)")'
@when(re(f'we run "jrnl ?{command}" and {input_method} {all_input}')) @when(re(f'we run "jrnl ?{command}" and {input_method} {all_input}'))
@when(parse('we run "jrnl {command}"')) @when(parse('we run "jrnl {command}"'))
@when('we run "jrnl"') @when('we run "jrnl"')
def we_run_jrnl(cli_run, capsys, keyring): def we_run_jrnl(cli_run, capsys, keyring, request, command, input_method, all_input):
from keyring import set_keyring from keyring import set_keyring
set_keyring(keyring) set_keyring(keyring)
# fixture injection (pytest-bdd >=6.0)
inject_fixture(request, "command", command)
with ExitStack() as stack: with ExitStack() as stack:
mocks = cli_run["mocks"] mocks = cli_run["mocks"]
factories = cli_run["mock_factories"] factories = cli_run["mock_factories"]