Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions wpull/application/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,7 @@ def _add_accept_args(self):
'-R',
'--reject',
metavar='LIST',
type=self.comma_list,
help=_('don’t download files with suffix in LIST'),
)
group.add_argument(
Expand Down
29 changes: 29 additions & 0 deletions wpull/application/options_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,32 @@ def test_exit(status=0, message=None):
self.assertEqual(2, error.args[0])
else:
self.assertTrue(False)

def test_comma_list_args(self):
arg_item_list = [
'--accept', '--reject',
'--domains', '--exclude-domains',
'--hostnames', '--exclude-hostnames',
'--follow-tags', '--ignore-tags',
'--include-directories', '--exclude-directories',
'--proxy-domains', '--proxy-exclude-domains',
'--proxy-hostnames', '--proxy-exclude-hostnames',
]
arg_dest_list = [
'accept', 'reject',
'domains', 'exclude_domains',
'hostnames', 'exclude_hostnames',
'follow_tags', 'ignore_tags',
'include_directories', 'exclude_directories',
'proxy_domains', 'proxy_exclude_domains',
'proxy_hostnames', 'proxy_exclude_hostnames',
]

cli_input = 'item1,item2,item3'
expected_value = ['item1', 'item2', 'item3']

for arg_item, arg_dest in zip(arg_item_list, arg_dest_list):
arg_parser = AppArgumentParser()

args = arg_parser.parse_args(['http://example.invalid'] + [arg_item, cli_input])
self.assertEqual(expected_value, vars(args)[arg_dest])