Skip to content

Commit

Permalink
update test for nargs list default transformation to also test initia…
Browse files Browse the repository at this point in the history
…l values are handled correctly
  • Loading branch information
Jozsef Kutas committed Oct 24, 2021
1 parent 9f6c832 commit 8d9a17a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions gooey/tests/test_argparse_to_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ def test_textinput_with_list_default_mapped_to_cli_friendly_value(self):
Using nargs and a `default` value with a list causes the literal list string
to be put into the UI.
Also tests initial_value - see issue #756.
"""
testcases = [
{'nargs': '+', 'default': ['a b', 'c'], 'gooey_default': '"a b" "c"', 'w': 'TextField'},
Expand Down Expand Up @@ -216,6 +218,13 @@ def test_textinput_with_list_default_mapped_to_cli_friendly_value(self):
result = argparse_to_json.handle_initial_values(action, case['w'], action.default)
self.assertEqual(result, case['gooey_default'])

gooey_parser = GooeyParser(prog='test_program')
options = {'initial_value': case['default']}
gooey_parser.add_argument('--foo', nargs=case['nargs'], gooey_options=options)
action = gooey_parser._actions[-1]
result = argparse_to_json.handle_initial_values(action, case['w'], case['default'])
self.assertEqual(result, case['gooey_default'])

def test_nargs(self):
"""
so there are just a few simple rules here:
Expand Down

0 comments on commit 8d9a17a

Please sign in to comment.