mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-12 09:28:31 +02:00
fix get_fixture function
This commit is contained in:
parent
9bb92707d0
commit
3956b75698
4 changed files with 17 additions and 10 deletions
|
@ -262,7 +262,9 @@ class Journal:
|
|||
start_date = time.parse(start_date)
|
||||
|
||||
# If strict mode is on, all tags have to be present in entry
|
||||
has_tags = self.search_tags.issubset if strict else self.search_tags.intersection
|
||||
has_tags = (
|
||||
self.search_tags.issubset if strict else self.search_tags.intersection
|
||||
)
|
||||
|
||||
def excluded(tags):
|
||||
return 0 < len([tag for tag in tags if tag in excluded_tags])
|
||||
|
|
|
@ -25,13 +25,16 @@ Feature: Change entry times in journal
|
|||
Scenario Outline: Change flag changes prompted entries
|
||||
Given we use the config "<config_file>"
|
||||
And we use the password "test" if prompted
|
||||
When we run "jrnl -1"
|
||||
Then the output should contain "2020-09-24 09:14 The third entry finally"
|
||||
When we run "jrnl --short"
|
||||
Then the output should be
|
||||
2020-08-29 11:11 Entry the first.
|
||||
2020-08-31 14:32 A second entry in what I hope to be a long series.
|
||||
2020-09-24 09:14 The third entry finally after weeks without writing.
|
||||
When we run "jrnl --change-time '2022-04-23 10:30'" and enter
|
||||
Y
|
||||
N
|
||||
Y
|
||||
When we run "jrnl -99 --short"
|
||||
When we run "jrnl --short"
|
||||
Then the output should be
|
||||
2020-08-31 14:32 A second entry in what I hope to be a long series.
|
||||
2022-04-23 10:30 Entry the first.
|
||||
|
|
|
@ -231,13 +231,15 @@ def mock_user_input(request, password_input, stdin_input):
|
|||
def _mock_user_input():
|
||||
# user_input needs to be here because we don't know it until cli_run starts
|
||||
user_input = get_fixture(request, "all_input", None)
|
||||
|
||||
if user_input is None:
|
||||
user_input = Exception("Unexpected call for user input")
|
||||
else:
|
||||
user_input = iter(user_input.splitlines())
|
||||
|
||||
def mock_console_input(**kwargs):
|
||||
if kwargs["password"] and not isinstance(password_input, Exception):
|
||||
pw = kwargs.get("password", False)
|
||||
if pw and not isinstance(password_input, Exception):
|
||||
return password_input
|
||||
|
||||
if isinstance(user_input, Iterable):
|
||||
|
@ -246,7 +248,7 @@ def mock_user_input(request, password_input, stdin_input):
|
|||
return "" if input_line == r"\n" else input_line
|
||||
|
||||
# exceptions
|
||||
return user_input if not kwargs["password"] else password_input
|
||||
return user_input if not pw else password_input
|
||||
|
||||
mock_console = Mock(wraps=Console(stderr=True))
|
||||
mock_console.input = Mock(side_effect=mock_console_input)
|
||||
|
|
|
@ -77,7 +77,7 @@ def spy_wrapper(wrapped_function):
|
|||
|
||||
|
||||
def get_fixture(request, name, default=None):
|
||||
result = default
|
||||
if name in request.node.fixturenames:
|
||||
result = request.getfixturevalue(name)
|
||||
return result
|
||||
try:
|
||||
return request.getfixturevalue(name)
|
||||
except LookupError:
|
||||
return default
|
||||
|
|
Loading…
Add table
Reference in a new issue