Use pytest-bdd 6 (#1685)

* update pytest-bdd to 6.0
* update lock file
* fix first test (inject command fixture to request)
* fix some more tests
* fix cli_run fixture
* fix password fixture
* Remove unused import
* Fix greedy should_or_should_not parsing problems while also consolidating its parse/transformation-to-bool code
* Prevent greedy matching in "we run" by using regular expression lookahead
* Add missing "Outline" in scenario outlines with examples
* Split "we use the config" and "we use no config" so pytest won't try to consume config_file as a fixture
* Fix missing ShouldOrShouldNot
* Formatting
* fix get_fixture function
* change output of failing test to be a little more useful
* update lock file
* update type builder to for should/should not to be in it's own file, rename some vars for readability
* add parse-type new dev/testing dependency
* update lock file

---------

Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
This commit is contained in:
Micah Jerome Ellison 2023-03-04 12:37:06 -08:00 committed by GitHub
parent 2d0b15ea7b
commit 1a67fd5dec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 136 additions and 127 deletions

View file

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