From 8494ae30d661f246d5c59118d8df5395dd456a7a Mon Sep 17 00:00:00 2001 From: angrybayblade Date: Mon, 30 Oct 2023 19:12:43 +0530 Subject: [PATCH] test: add_numbers.py coverage --- tests/test_examples/test_add_number.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/test_examples/test_add_number.py diff --git a/tests/test_examples/test_add_number.py b/tests/test_examples/test_add_number.py new file mode 100644 index 0000000..e6be4f2 --- /dev/null +++ b/tests/test_examples/test_add_number.py @@ -0,0 +1,21 @@ +"""Test add.py""" + +from examples.add_numbers import add as cli +from clea.runner import run + + +def test_missing_arguments() -> None: + """Test add.""" + result = run(cli=cli, argv=[], isolated=True) + assert result.exit_code == 1 + assert ( + "Missing argument for positional arguments , " + in result.stderr + ) + + +def test_add() -> None: + """Test add.""" + result = run(cli=cli, argv=["1", "2"], isolated=True) + assert result.exit_code == 0 + assert "Total 3" in result.stdout