Merge branch 'develop' into black

This commit is contained in:
Jonathan Wren 2019-12-21 12:11:05 -08:00 committed by GitHub
commit e984a9a015
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 32 deletions

View file

@ -61,11 +61,12 @@ def open_journal(journal_name="default"):
config = util.load_config(install.CONFIG_FILE_PATH) config = util.load_config(install.CONFIG_FILE_PATH)
journal_conf = config["journals"][journal_name] journal_conf = config["journals"][journal_name]
# We can override the default config on a by-journal basis
if type(journal_conf) is dict: if type(journal_conf) is dict:
# We can override the default config on a by-journal basis
config.update(journal_conf) config.update(journal_conf)
# But also just give them a string to point to the journal file
else: else:
# But also just give them a string to point to the journal file
config["journal"] = journal_conf config["journal"] = journal_conf
return Journal.open_journal(journal_name, config) return Journal.open_journal(journal_name, config)
@ -129,25 +130,27 @@ def run_with_input(context, command, inputs=""):
text = iter([inputs]) text = iter([inputs])
args = ushlex(command)[1:] args = ushlex(command)[1:]
# fmt: off
# black needs the 'on' and 'off' to be at the same indentation level
with patch("builtins.input", side_effect=_mock_input(text)) as mock_input,\
patch("getpass.getpass", side_effect=_mock_getpass(text)) as mock_getpass,\
patch("sys.stdin.read", side_effect=text) as mock_read:
try:
cli.run(args or [])
context.exit_status = 0
except SystemExit as e:
context.exit_status = e.code
# at least one of the mocked input methods got called # fmt: off
assert mock_input.called or mock_getpass.called or mock_read.called # see: https://github.com/psf/black/issues/557
# all inputs were used with patch("builtins.input", side_effect=_mock_input(text)) as mock_input, \
try: patch("getpass.getpass", side_effect=_mock_getpass(text)) as mock_getpass, \
next(text) patch("sys.stdin.read", side_effect=text) as mock_read:
assert False, "Not all inputs were consumed"
except StopIteration: try:
pass cli.run(args or [])
context.exit_status = 0
except SystemExit as e:
context.exit_status = e.code
# at least one of the mocked input methods got called
assert mock_input.called or mock_getpass.called or mock_read.called
# all inputs were used
try:
next(text)
assert False, "Not all inputs were consumed"
except StopIteration:
pass
# fmt: on # fmt: on

View file

@ -231,18 +231,16 @@ class Journal:
result = [ result = [
entry entry
for entry in self.entries for entry in self.entries
if ( if (not tags or tagged(entry.tags))
(not tags or tagged(entry.tags)) and (not starred or entry.starred)
and (not starred or entry.starred) and (not start_date or entry.date >= start_date)
and (not start_date or entry.date >= start_date) and (not end_date or entry.date <= end_date)
and (not end_date or entry.date <= end_date) and (not exclude or not excluded(entry.tags))
and (not exclude or not excluded(entry.tags)) and (
and ( not contains
not contains or (
or ( contains_lower in entry.title.casefold()
contains_lower in entry.title.casefold() or contains_lower in entry.body.casefold()
or contains_lower in entry.body.casefold()
)
) )
) )
] ]