add all options even if already set by user

This commit is contained in:
2019-07-28 09:15:31 +02:00
parent 4e2c37822c
commit 9bc52bcbbb
3 changed files with 136 additions and 109 deletions

View File

@ -290,17 +290,18 @@ def test_leadership_modif_mandatory(json):
'leader.follower_choice': [None],
'leader.follower_integer': [None],
'leader.follower_submulti': [['255.255.255.128']]}
output2 = """usage: prog.py --leader.leader ['192.168.1.1'] [-h]
[--leader.pop-leader INDEX]
[--leader.follower INDEX [FOLLOWER]]
--leader.follower_submulti
INDEX [FOLLOWER_SUBMULTI ...]
[--leader.follower_integer INDEX [FOLLOWER_INTEGER]]
[--leader.follower_boolean INDEX]
[--leader.no-follower_boolean INDEX]
[--leader.follower_choice INDEX [{opt1,opt2}]]
--leader.follower_mandatory
INDEX FOLLOWER_MANDATORY
output2 = """usage: prog.py --leader.leader "192.168.1.1" [-h]
[--leader.leader [LEADER [LEADER ...]]]
[--leader.pop-leader INDEX]
[--leader.follower INDEX [FOLLOWER]]
--leader.follower_submulti INDEX
[FOLLOWER_SUBMULTI ...]
[--leader.follower_integer INDEX [FOLLOWER_INTEGER]]
[--leader.follower_boolean INDEX]
[--leader.no-follower_boolean INDEX]
[--leader.follower_choice INDEX [{opt1,opt2}]]
--leader.follower_mandatory INDEX
FOLLOWER_MANDATORY
prog.py: error: the following arguments are required: --leader.follower_submulti"""
config = get_config(json, with_mandatory=True)

View File

@ -131,7 +131,10 @@ root:
def test_readme_help_modif_positional(json):
output = """usage: prog.py str [-h] [-v] [-nv] --str STR
output = """usage: prog.py "str" [-h] [-v] [-nv] --str STR {str,list,int,none}
positional arguments:
{str,list,int,none} choice the sub argument
optional arguments:
-h, --help show this help message and exit
@ -152,12 +155,17 @@ optional arguments:
def test_readme_help_modif(json):
output = """usage: prog.py str --str toto [-h] [-v] [-nv]
output = """usage: prog.py "str" --str "toto" [-h] [-v] [-nv] --str STR
{str,list,int,none}
positional arguments:
{str,list,int,none} choice the sub argument
optional arguments:
-h, --help show this help message and exit
-v, --verbosity increase output verbosity
-nv, --no-verbosity
--str STR string option
"""
parser = TiramisuCmdlineParser(get_config(json), 'prog.py')
f = StringIO()
@ -172,11 +180,16 @@ optional arguments:
def test_readme_help_modif_short1(json):
output = """usage: prog.py str --verbosity [-h] --str STR
output = """usage: prog.py "str" -v [-h] [-v] [-nv] --str STR {str,list,int,none}
positional arguments:
{str,list,int,none} choice the sub argument
optional arguments:
-h, --help show this help message and exit
--str STR string option
-h, --help show this help message and exit
-v, --verbosity increase output verbosity
-nv, --no-verbosity
--str STR string option
"""
parser = TiramisuCmdlineParser(get_config(json), 'prog.py')
f = StringIO()
@ -191,11 +204,16 @@ optional arguments:
def test_readme_help_modif_short_no(json):
output = """usage: prog.py str --verbosity [-h] --str STR
output = """usage: prog.py "str" -v [-h] [-v] [-nv] --str STR {str,list,int,none}
positional arguments:
{str,list,int,none} choice the sub argument
optional arguments:
-h, --help show this help message and exit
--str STR string option
-h, --help show this help message and exit
-v, --verbosity increase output verbosity
-nv, --no-verbosity
--str STR string option
"""
parser = TiramisuCmdlineParser(get_config(json), 'prog.py')
f = StringIO()
@ -258,7 +276,7 @@ prog.py: error: the following arguments are required: cmd
def test_readme_mandatory(json):
output = """usage: prog.py str [-h] [-v] [-nv] --str STR
output = """usage: prog.py "str" [-h] [-v] [-nv] --str STR {str,list,int,none}
prog.py: error: the following arguments are required: --str
"""
parser = TiramisuCmdlineParser(get_config(json), 'prog.py')
@ -274,7 +292,7 @@ prog.py: error: the following arguments are required: --str
def test_readme_mandatory_tree(json):
output = """usage: prog.py str [-h] [-v] [-nv] --root.str STR
output = """usage: prog.py "str" [-h] [-v] [-nv] --root.str STR {str,list,int,none}
prog.py: error: the following arguments are required: --root.str
"""
parser = TiramisuCmdlineParser(get_config(json, True), 'prog.py')
@ -290,7 +308,7 @@ prog.py: error: the following arguments are required: --root.str
def test_readme_mandatory_tree_flatten(json):
output = """usage: prog.py str [-h] [-v] [-nv] --str STR
output = """usage: prog.py "str" [-h] [-v] [-nv] --str STR {str,list,int,none}
prog.py: error: the following arguments are required: --str
"""
parser = TiramisuCmdlineParser(get_config(json, True), 'prog.py', fullpath=False)
@ -306,7 +324,7 @@ prog.py: error: the following arguments are required: --str
def test_readme_cross(json):
output = """usage: prog.py none [-h] [-v] [-nv]
output = """usage: prog.py "none" [-h] [-v] [-nv] {str,list,int,none}
prog.py: error: unrecognized arguments: --int
"""
parser = TiramisuCmdlineParser(get_config(json), 'prog.py')
@ -322,7 +340,7 @@ prog.py: error: unrecognized arguments: --int
def test_readme_cross_tree(json):
output = """usage: prog.py none [-h] [-v] [-nv]
output = """usage: prog.py "none" [-h] [-v] [-nv] {str,list,int,none}
prog.py: error: unrecognized arguments: --int
"""
parser = TiramisuCmdlineParser(get_config(json, True), 'prog.py')
@ -338,7 +356,7 @@ prog.py: error: unrecognized arguments: --int
def test_readme_cross_tree_flatten(json):
output = """usage: prog.py none [-h] [-v] [-nv]
output = """usage: prog.py "none" [-h] [-v] [-nv] {str,list,int,none}
prog.py: error: unrecognized arguments: --int
"""
parser = TiramisuCmdlineParser(get_config(json, True), 'prog.py', fullpath=False)