From 181f5402bd9c6d3ae8ac180927cb7add5c1bdda3 Mon Sep 17 00:00:00 2001 From: zrr1999 <2742392377@qq.com> Date: Sun, 20 Oct 2024 15:09:19 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20test:=20add=20tests=20for=20error?= =?UTF-8?q?=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/error.toml | 4 ++++ tests/test_e2e.py | 10 ++++++++++ 2 files changed, 14 insertions(+) create mode 100644 examples/error.toml diff --git a/examples/error.toml b/examples/error.toml new file mode 100644 index 0000000..37c61f9 --- /dev/null +++ b/examples/error.toml @@ -0,0 +1,4 @@ +name = "error example" + +[tasks.a] +command = "undefined command" diff --git a/tests/test_e2e.py b/tests/test_e2e.py index 8f1554a..7968ab8 100644 --- a/tests/test_e2e.py +++ b/tests/test_e2e.py @@ -18,6 +18,16 @@ def test_cli(config_path: str): assert result.exit_code == 0, f"Exit code was {result.exit_code}, expected 0. Error: {result.exc_info}" +def test_cli_error(): + from typer.testing import CliRunner + + from nanoflow.__main__ import app + + runner = CliRunner() + result = runner.invoke(app, ["./examples/error.toml"]) + assert result.exit_code != 0 + + @pytest.mark.asyncio async def test_tui(): import toml