From 4905dd5e31e9ba13630e2e86cda9ed1e94c3c978 Mon Sep 17 00:00:00 2001 From: Wes Turner Date: Thu, 1 Oct 2020 11:27:29 -0400 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=90=9B=20FIX:=20cli.parse:=20return?= =?UTF-8?q?=200=20for=20non-error=20#53?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- markdown_it/cli/parse.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/markdown_it/cli/parse.py b/markdown_it/cli/parse.py index ac8ccddd..f884c939 100644 --- a/markdown_it/cli/parse.py +++ b/markdown_it/cli/parse.py @@ -14,7 +14,8 @@ def main(args=None): convert(namespace.filenames) else: interactive() - return True + RET_OK = 0 + return RET_OK def convert(filenames): From 1d71c4c2038eae915091c5ec06afc87819f3a3fe Mon Sep 17 00:00:00 2001 From: Wes Turner Date: Thu, 1 Oct 2020 11:40:04 -0400 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=A7=AA=20TEST:=20fix=20and=20add=20a?= =?UTF-8?q?=20CLI=20returncode=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_cli.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 191ea0fb..801959ef 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -2,6 +2,8 @@ import tempfile from unittest.mock import patch +import pytest + from markdown_it.cli import parse @@ -9,7 +11,12 @@ def test_parse(): with tempfile.TemporaryDirectory() as tempdir: path = pathlib.Path(tempdir).joinpath("test.md") path.write_text("a b c") - assert parse.main([str(path)]) + assert parse.main([str(path)]) == 0 + + +def test_parse_fail(): + with pytest.raises(SystemExit): + parse.main(["/tmp/nonexistant_path/for_cli_test.md"]) def test_print_heading(): From 5434e30791cc6788257e06d1e921654555f44280 Mon Sep 17 00:00:00 2001 From: Wes Turner <50891+westurner@users.noreply.github.com> Date: Sat, 24 Oct 2020 11:52:56 -0400 Subject: [PATCH 3/3] TEST: tests/test_cli.py: check SysyemExit exc_info return code Co-authored-by: Taneli Hukkinen --- tests/test_cli.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 801959ef..75942442 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -15,8 +15,9 @@ def test_parse(): def test_parse_fail(): - with pytest.raises(SystemExit): + with pytest.raises(SystemExit) as exc_info: parse.main(["/tmp/nonexistant_path/for_cli_test.md"]) + assert exc_info.value.code == 1 def test_print_heading():