Skip to content

Commit 571a9b6

Browse files
committed
test handling of invalid CLI flags in argument parser
1 parent adfe9bc commit 571a9b6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/test_argsParser.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,12 @@ def test_arg_parser_token_usage_option_short(mock_config):
113113
with patch("sys.argv", ["code_mage.py", "-t"]):
114114
args = arg_parser(mock_config)
115115
assert args.token_usage is True
116+
117+
118+
# Test invalid flag argument option
119+
def test_arg_parser_invalid_option():
120+
with patch("sys.argv", ["code_mage.py", "--invalid"]):
121+
with pytest.raises(SystemExit) as excinfo:
122+
arg_parser({})
123+
assert excinfo.type is SystemExit
124+
assert excinfo.value.code != 0

0 commit comments

Comments
 (0)