From 2894118d7cc57db31ede8fff21e2d590b0a38972 Mon Sep 17 00:00:00 2001 From: Micah Jerome Ellison Date: Sat, 26 Dec 2020 15:04:08 -0800 Subject: [PATCH] Properly use patched config path and add config given to scenario that wasn't using it --- features/core.feature | 1 + features/steps/core.py | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/features/core.feature b/features/core.feature index 26640c00..a436219f 100644 --- a/features/core.feature +++ b/features/core.feature @@ -13,6 +13,7 @@ Feature: Functionality of jrnl outside of actually handling journals Then the output should match "^jrnl version v\d+\.\d+(\.\d+)?(-(alpha|beta)\d*)?" Scenario: Running the diagnostic command + Given we use the config "simple.yaml" When we run "jrnl --diagnostic" Then the output should contain "jrnl" And the output should contain "Python" diff --git a/features/steps/core.py b/features/steps/core.py index 3e873448..4d728c16 100644 --- a/features/steps/core.py +++ b/features/steps/core.py @@ -125,8 +125,6 @@ def read_value_from_string(string): value = {"bool": lambda v: v.lower() == "true", "int": int, "str": str}[t](value) return value -def get_test_config_path(context): - return context.config_path @given('we use the config "{config_file}"') def set_config(context, config_file): @@ -308,8 +306,8 @@ def run_with_input(context, command, inputs=""): patch("getpass.getpass", side_effect=_mock_getpass(password)) as mock_getpass, \ patch("sys.stdin.read", side_effect=text) as mock_read, \ patch("subprocess.call", side_effect=_mock_editor) as mock_editor, \ - patch("jrnl.config.get_config_path", side_effect=get_test_config_path(context)), \ - patch("jrnl.install.get_config_path", side_effect=get_test_config_path(context)) \ + patch("jrnl.config.get_config_path", side_effect=lambda: context.config_path), \ + patch("jrnl.install.get_config_path", side_effect=lambda: context.config_path) \ : try: cli(args or []) @@ -392,8 +390,8 @@ def run(context, command, text=""): patch("getpass.getpass", side_effect=_mock_getpass(password)) as mock_getpass, \ patch("subprocess.call", side_effect=_mock_editor) as mock_editor, \ patch("sys.stdin.read", side_effect=lambda: text), \ - patch("jrnl.config.get_config_path", side_effect=get_test_config_path(context)), \ - patch("jrnl.install.get_config_path", side_effect=get_test_config_path(context)) \ + 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.getpass = mock_getpass