From 571a9b6afcbfa7449c1de3cc95318d2c76dc34f1 Mon Sep 17 00:00:00 2001 From: Arina Kolodeznikova Date: Fri, 15 Nov 2024 17:45:25 -0500 Subject: [PATCH] test handling of invalid CLI flags in argument parser --- tests/test_argsParser.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_argsParser.py b/tests/test_argsParser.py index 06f724a..a8bc843 100644 --- a/tests/test_argsParser.py +++ b/tests/test_argsParser.py @@ -113,3 +113,12 @@ def test_arg_parser_token_usage_option_short(mock_config): with patch("sys.argv", ["code_mage.py", "-t"]): args = arg_parser(mock_config) assert args.token_usage is True + + +# Test invalid flag argument option +def test_arg_parser_invalid_option(): + with patch("sys.argv", ["code_mage.py", "--invalid"]): + with pytest.raises(SystemExit) as excinfo: + arg_parser({}) + assert excinfo.type is SystemExit + assert excinfo.value.code != 0 \ No newline at end of file