mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-17 11:38:32 +02:00
Fix compatibility with pytest-bdd 6
This commit is contained in:
parent
76392620be
commit
02cf930f1d
4 changed files with 30 additions and 7 deletions
|
@ -50,7 +50,7 @@ mkdocs = ">=1.0,<1.3"
|
||||||
poethepoet = "*"
|
poethepoet = "*"
|
||||||
pyproject-flake8 = "*"
|
pyproject-flake8 = "*"
|
||||||
pytest = ">=6.2"
|
pytest = ">=6.2"
|
||||||
pytest-bdd = ">=4.0.1,<6.0"
|
pytest-bdd = ">=4.0.1,<7.0"
|
||||||
pytest-clarity = "*"
|
pytest-clarity = "*"
|
||||||
pytest-xdist = ">=2.5.0"
|
pytest-xdist = ">=2.5.0"
|
||||||
requests = "*"
|
requests = "*"
|
||||||
|
@ -168,7 +168,7 @@ isolated_build = True
|
||||||
[testenv]
|
[testenv]
|
||||||
deps =
|
deps =
|
||||||
pytest >= 6.2
|
pytest >= 6.2
|
||||||
pytest-bdd >=4.0.1,<6.0
|
pytest-bdd >=4.0.1,<7.0
|
||||||
pytest-xdist >=2.5.0
|
pytest-xdist >=2.5.0
|
||||||
toml >=0.10
|
toml >=0.10
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ from xml.etree import ElementTree
|
||||||
|
|
||||||
from pytest_bdd import given
|
from pytest_bdd import given
|
||||||
from pytest_bdd.parsers import parse
|
from pytest_bdd.parsers import parse
|
||||||
|
from pytest_bdd.steps import inject_fixture
|
||||||
|
|
||||||
from jrnl import __version__
|
from jrnl import __version__
|
||||||
from jrnl.time import __get_pdt_calendar
|
from jrnl.time import __get_pdt_calendar
|
||||||
|
@ -77,8 +78,13 @@ def we_have_type_of_keyring(keyring_type):
|
||||||
|
|
||||||
|
|
||||||
@given(parse('we use the config "{config_file}"'), target_fixture="config_path")
|
@given(parse('we use the config "{config_file}"'), target_fixture="config_path")
|
||||||
|
def we_use_the_config(request, config_file, temp_dir, working_dir):
|
||||||
|
inject_fixture(request, "config_file", config_file)
|
||||||
|
return we_use_no_config(request, temp_dir, working_dir)
|
||||||
|
|
||||||
|
|
||||||
@given(parse("we use no config"), target_fixture="config_path")
|
@given(parse("we use no config"), target_fixture="config_path")
|
||||||
def we_use_the_config(request, temp_dir, working_dir):
|
def we_use_no_config(request, temp_dir, working_dir):
|
||||||
config_file = get_fixture(request, "config_file")
|
config_file = get_fixture(request, "config_file")
|
||||||
|
|
||||||
# Move into temp dir as cwd
|
# Move into temp dir as cwd
|
||||||
|
@ -113,13 +119,15 @@ def we_use_the_config(request, temp_dir, working_dir):
|
||||||
|
|
||||||
|
|
||||||
@given(parse('the config "{config_file}" exists'), target_fixture="config_path")
|
@given(parse('the config "{config_file}" exists'), target_fixture="config_path")
|
||||||
def config_exists(config_file, temp_dir, working_dir):
|
def config_exists(request, config_file, temp_dir, working_dir):
|
||||||
config_source = os.path.join(working_dir, "data", "configs", config_file)
|
config_source = os.path.join(working_dir, "data", "configs", config_file)
|
||||||
config_dest = os.path.join(temp_dir.name, config_file)
|
config_dest = os.path.join(temp_dir.name, config_file)
|
||||||
shutil.copy2(config_source, config_dest)
|
shutil.copy2(config_source, config_dest)
|
||||||
|
inject_fixture(request, "config_file", config_file)
|
||||||
|
return config_dest
|
||||||
|
|
||||||
|
|
||||||
@given(parse('we use the password "{password}" if prompted'))
|
@given(parse('we use the password "{password}" if prompted'), target_fixture="password")
|
||||||
def use_password_forever(password):
|
def use_password_forever(password):
|
||||||
return password
|
return password
|
||||||
|
|
||||||
|
|
|
@ -127,6 +127,8 @@ def default_journal_location(journal_file, journal_dir, config_on_disk, temp_dir
|
||||||
assert os.path.samefile(default_journal_path, expected_journal_path)
|
assert os.path.samefile(default_journal_path, expected_journal_path)
|
||||||
|
|
||||||
|
|
||||||
|
@then(parse('the config {should_or_should_not} contain "{some_yaml}"'))
|
||||||
|
@then(parse("the config {should_or_should_not} contain\n{some_yaml}"))
|
||||||
@then(
|
@then(
|
||||||
parse(
|
parse(
|
||||||
'the config for journal "{journal_name}" {should_or_should_not} contain "{some_yaml}"'
|
'the config for journal "{journal_name}" {should_or_should_not} contain "{some_yaml}"'
|
||||||
|
@ -137,8 +139,6 @@ def default_journal_location(journal_file, journal_dir, config_on_disk, temp_dir
|
||||||
'the config for journal "{journal_name}" {should_or_should_not} contain\n{some_yaml}'
|
'the config for journal "{journal_name}" {should_or_should_not} contain\n{some_yaml}'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@then(parse('the config {should_or_should_not} contain "{some_yaml}"'))
|
|
||||||
@then(parse("the config {should_or_should_not} contain\n{some_yaml}"))
|
|
||||||
def config_var_on_disk(config_on_disk, journal_name, should_or_should_not, some_yaml):
|
def config_var_on_disk(config_on_disk, journal_name, should_or_should_not, some_yaml):
|
||||||
we_should = parse_should_or_should_not(should_or_should_not)
|
we_should = parse_should_or_should_not(should_or_should_not)
|
||||||
|
|
||||||
|
|
|
@ -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.cli import cli
|
from jrnl.cli import cli
|
||||||
|
|
||||||
|
@ -29,7 +30,21 @@ all_input = '("(?P<all_input>[^"]*)")'
|
||||||
|
|
||||||
@when(parse('we run "jrnl {command}" and {input_method}\n{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(re(f'we run "jrnl ?{command}" and {input_method} {all_input}'))
|
||||||
|
def we_run_jrnl_with_all_args(
|
||||||
|
request, command, input_method, all_input, cli_run, capsys, keyring
|
||||||
|
):
|
||||||
|
inject_fixture(request, "command", command)
|
||||||
|
inject_fixture(request, "input_method", input_method)
|
||||||
|
inject_fixture(request, "all_input", all_input)
|
||||||
|
return we_run_jrnl(cli_run, capsys, keyring)
|
||||||
|
|
||||||
|
|
||||||
@when(parse('we run "jrnl {command}"'))
|
@when(parse('we run "jrnl {command}"'))
|
||||||
|
def we_run_jrnl_with_cmd(request, command, cli_run, capsys, keyring):
|
||||||
|
inject_fixture(request, "command", command)
|
||||||
|
return we_run_jrnl(cli_run, capsys, keyring)
|
||||||
|
|
||||||
|
|
||||||
@when('we run "jrnl"')
|
@when('we run "jrnl"')
|
||||||
def we_run_jrnl(cli_run, capsys, keyring):
|
def we_run_jrnl(cli_run, capsys, keyring):
|
||||||
from keyring import set_keyring
|
from keyring import set_keyring
|
||||||
|
|
Loading…
Add table
Reference in a new issue