Fix editor test that needed patched config and trapping for system exit

This commit is contained in:
Micah Jerome Ellison 2020-12-26 15:43:38 -08:00
parent 80072b5b3d
commit 91049eda6c

View file

@ -194,11 +194,18 @@ def open_editor_and_enter(context, method, text=""):
with \ with \
patch("subprocess.call", side_effect=_mock_editor) as mock_editor, \ patch("subprocess.call", side_effect=_mock_editor) as mock_editor, \
patch("getpass.getpass", side_effect=_mock_getpass(password)) as mock_getpass, \ patch("getpass.getpass", side_effect=_mock_getpass(password)) as mock_getpass, \
patch("sys.stdin.isatty", return_value=True) \ patch("sys.stdin.isatty", return_value=True), \
patch("jrnl.config.get_config_path", side_effect=lambda: context.config_path), \
patch("jrnl.install.get_config_path", side_effect=lambda: context.config_path) \
: :
context.editor = mock_editor context.editor = mock_editor
context.getpass = mock_getpass context.getpass = mock_getpass
cli(["--edit"]) try:
cli(["--edit"])
context.exit_status = 0
except SystemExit as e:
context.exit_status = e.code
# fmt: on # fmt: on