From 12e8343068b906f8b2afddc5569968a8a91fa5b0 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 29 Apr 2024 06:24:24 +0200 Subject: Adding upstream version 2.1.0. Signed-off-by: Daniel Baumann --- tests/test_cli.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/test_cli.py (limited to 'tests/test_cli.py') diff --git a/tests/test_cli.py b/tests/test_cli.py new file mode 100644 index 0000000..57d6b93 --- /dev/null +++ b/tests/test_cli.py @@ -0,0 +1,36 @@ +import pathlib +import tempfile +from unittest.mock import patch + +import pytest + +from markdown_it.cli import parse + + +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)]) == 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(): + with patch("builtins.print") as patched: + parse.print_heading() + patched.assert_called() + + +def test_interactive(): + def mock_input(prompt): + raise KeyboardInterrupt + + with patch("builtins.print") as patched: + with patch("builtins.input", mock_input): + parse.interactive() + patched.assert_called() -- cgit v1.2.3