mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-07-03 23:16:14 +02:00
(closer to) being able to run behave tests outside project root directory
This commit is contained in:
parent
96f1d77cdc
commit
c990c8c9ad
4 changed files with 63 additions and 47 deletions
|
@ -21,6 +21,9 @@ from jrnl import Journal
|
|||
from jrnl import __version__
|
||||
from jrnl import plugins
|
||||
from jrnl.args import parse_args
|
||||
from jrnl.behave_testing import _mock_getpass
|
||||
from jrnl.behave_testing import _mock_input
|
||||
from jrnl.behave_testing import _mock_time_parse
|
||||
from jrnl.cli import cli
|
||||
from jrnl.config import load_config
|
||||
from jrnl.os_compat import split_args
|
||||
|
@ -278,42 +281,6 @@ def extension_editor_file(context, suffix):
|
|||
assert filename_suffix == suffix
|
||||
|
||||
|
||||
def _mock_getpass(inputs):
|
||||
def prompt_return(prompt=""):
|
||||
if type(inputs) == str:
|
||||
return inputs
|
||||
try:
|
||||
return next(inputs)
|
||||
except StopIteration:
|
||||
raise KeyboardInterrupt
|
||||
|
||||
return prompt_return
|
||||
|
||||
|
||||
def _mock_input(inputs):
|
||||
def prompt_return(prompt=""):
|
||||
try:
|
||||
val = next(inputs)
|
||||
print(prompt, val)
|
||||
return val
|
||||
except StopIteration:
|
||||
raise KeyboardInterrupt
|
||||
|
||||
return prompt_return
|
||||
|
||||
|
||||
def _mock_time_parse(context):
|
||||
original_parse = jrnl.time.parse
|
||||
if "now" not in context:
|
||||
return original_parse
|
||||
|
||||
def wrapper(input, *args, **kwargs):
|
||||
input = context.now if input == "now" else input
|
||||
return original_parse(input, *args, **kwargs)
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
@when('we run "{command}" and enter')
|
||||
@when('we run "{command}" and enter nothing')
|
||||
@when('we run "{command}" and enter "{inputs}"')
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
from jrnl.jrnl import run
|
||||
from unittest import mock
|
||||
|
||||
# from __future__ import with_statement
|
||||
from jrnl.args import parse_args
|
||||
from behave import then
|
||||
|
||||
from features.steps.core import _mock_getpass, _mock_time_parse
|
||||
from jrnl.args import parse_args
|
||||
from jrnl.behave_testing import _mock_getpass
|
||||
from jrnl.behave_testing import _mock_time_parse
|
||||
from jrnl.jrnl import run
|
||||
|
||||
|
||||
@then("the editor {editor} should have been called")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue