From 6a9773734a20a864cf4a826e407687f00b30bd5d Mon Sep 17 00:00:00 2001 From: Shane Kerr Date: Sat, 20 Nov 2021 11:07:39 +0100 Subject: [PATCH 1/2] Fix crash if no arguments are passed to cli --- humblebundle_downloader/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/humblebundle_downloader/cli.py b/humblebundle_downloader/cli.py index 2810a02..b964569 100644 --- a/humblebundle_downloader/cli.py +++ b/humblebundle_downloader/cli.py @@ -15,7 +15,7 @@ logging.getLogger('urllib3.connectionpool').setLevel(logging.WARNING) def parse_args(args): - if args[0].lower() == 'download': + if len(args) > 0 and args[0].lower() == 'download': args = args[1:] raise DeprecationWarning("`download` argument is no longer used") From 59db1ac33f6a91cdc0f07adb3a7cde6152e3bd6c Mon Sep 17 00:00:00 2001 From: Shane Kerr Date: Sat, 20 Nov 2021 11:12:50 +0100 Subject: [PATCH 2/2] Test case for cli startup without any arguments --- tests/test_cli.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/test_cli.py b/tests/test_cli.py index ae36d4d..bc838d7 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -11,3 +11,9 @@ def test_no_action(): args = parse_args(['-l', 'some_path', '-c', 'fake_cookie']) assert args.library_path == 'some_path' assert args.cookie_file == 'fake_cookie' + + +def test_no_args(): + with pytest.raises(SystemExit) as ex: + parse_args([]) + assert ex.value.code == 2