mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-06-27 21:16:14 +02:00
Move remaining tests from behave to pytest (#1346)
* add newer tests to pytest (from behave) * remove 'lib' from gitignore (since we're using it) * fix capitalization in some steps * add 'the editor should not have been called' step * comment out config override step in pytest-bdd since it's not implemented yet * remove test that didn't really test anything * implement some missing steps in pytest-bdd * change comment to match other tests
This commit is contained in:
parent
593245f3fd
commit
7d8823da6d
5 changed files with 167 additions and 5 deletions
|
@ -84,6 +84,14 @@ def output_should_contain_version(cli_run, toml_version):
|
|||
assert toml_version in out, toml_version
|
||||
|
||||
|
||||
@then(parse("the output should be {width:d} columns wide"))
|
||||
def output_should_be_columns_wide(cli_run, width):
|
||||
out = cli_run["stdout"]
|
||||
out_lines = out.splitlines()
|
||||
for line in out_lines:
|
||||
assert len(line) <= width
|
||||
|
||||
|
||||
@then(parse('we should see the message "{text}"'))
|
||||
def should_see_the_message(text, cli_run):
|
||||
out = cli_run["stderr"]
|
||||
|
@ -301,15 +309,34 @@ def count_elements(number, item, cli_run):
|
|||
assert len(xml_tree.findall(".//" + item)) == number
|
||||
|
||||
|
||||
@then(parse("the editor should have been called"))
|
||||
@then(parse("the editor should have been called with {num_args} arguments"))
|
||||
def count_editor_args(num_args, cli_run, editor_state):
|
||||
assert cli_run["mocks"]["editor"].called
|
||||
@then(parse("the editor {should_or_should_not} have been called"))
|
||||
@then(
|
||||
parse(
|
||||
"the editor {should_or_should_not} have been called with {num_args} arguments"
|
||||
)
|
||||
)
|
||||
def count_editor_args(num_args, cli_run, editor_state, should_or_should_not):
|
||||
we_should = parse_should_or_should_not(should_or_should_not)
|
||||
|
||||
if we_should:
|
||||
assert cli_run["mocks"]["editor"].called
|
||||
else:
|
||||
assert not cli_run["mocks"]["editor"].called
|
||||
|
||||
if isinstance(num_args, int):
|
||||
assert len(editor_state["command"]) == int(num_args)
|
||||
|
||||
|
||||
@then(parse("the stdin prompt {should_or_should_not} have been called"))
|
||||
def stdin_prompt_called(cli_run, should_or_should_not):
|
||||
we_should = parse_should_or_should_not(should_or_should_not)
|
||||
|
||||
if we_should:
|
||||
assert cli_run["mocks"]["stdin"].called
|
||||
else:
|
||||
assert not cli_run["mocks"]["stdin"].called
|
||||
|
||||
|
||||
@then(parse('the editor filename should end with "{suffix}"'))
|
||||
def editor_filename_suffix(suffix, editor_state):
|
||||
editor_filename = editor_state["tmpfile"]["name"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue