diff --git a/markdown_it/cli/parse.py b/markdown_it/cli/parse.py index 32374d31..59c2f826 100644 --- a/markdown_it/cli/parse.py +++ b/markdown_it/cli/parse.py @@ -20,7 +20,8 @@ def main(args=None): convert(namespace.filenames) else: interactive() - return True + RET_OK = 0 + return RET_OK def convert(filenames): diff --git a/tests/test_cli.py b/tests/test_cli.py index 191ea0fb..75942442 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,13 @@ 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) as exc_info: + parse.main(["/tmp/nonexistant_path/for_cli_test.md"]) + assert exc_info.value.code == 1 def test_print_heading():