From 3055cca76795e92e55b5e4044baf1a095fb1a6c5 Mon Sep 17 00:00:00 2001 From: Jonathan Wren Date: Sat, 13 Feb 2021 18:38:27 -0800 Subject: [PATCH] Add tests for core feature to pytest-bdd - Implement "the output should contain" step Co-authored-by: Micah Jerome Ellison --- pyproject.toml | 4 ++++ tests/features/core.feature | 10 ++++++++++ tests/step_defs/conftest.py | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index b8c4731e..37a2f6b3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,6 +65,10 @@ force_sort_within_sections = true [tool.pytest.ini_options] minversion = "6.0" +markers = [ + "todo", +] + [build-system] requires = ["poetry>=1.1"] diff --git a/tests/features/core.feature b/tests/features/core.feature index 67a73a12..4399341d 100644 --- a/tests/features/core.feature +++ b/tests/features/core.feature @@ -6,3 +6,13 @@ Feature: Functionality of jrnl outside of actually handling journals Then we should get no error 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" + And the output should contain "OS" + + @todo + Scenario: Listing available journals + diff --git a/tests/step_defs/conftest.py b/tests/step_defs/conftest.py index fb3b1da1..2e62c561 100644 --- a/tests/step_defs/conftest.py +++ b/tests/step_defs/conftest.py @@ -91,3 +91,10 @@ def matches_std_output(regex, cli_run): out = cli_run["stdout"] matches = re.findall(regex, out) assert matches, f"\nRegex didn't match:\n{regex}\n{str(out)}\n{str(matches)}" + + +@then(parse("the output should contain\n{text}")) +@then(parse('the output should contain "{text}"')) +def check_output_inline(text, cli_run): + assert text and text in cli_run['stdout'] +