remove empty OD in help if option remove_empty_od set to True

This commit is contained in:
2019-07-26 15:17:36 +02:00
parent e14b997a54
commit 3d0ac1fb19
3 changed files with 53 additions and 1 deletions

View File

@ -98,6 +98,41 @@ od2.subtree:
assert f.getvalue() == output
def test_optiondescription_help_remove_empty_od(json):
output = """usage: prog.py [-h] [-v] [-nv] --od2.subtree.str STR --od2.before BEFORE
--od2.after AFTER
{str,list,int,none}
optional arguments:
-h, --help show this help message and exit
od1.od0:
Sub-Tree 1
{str,list,int,none} choice the sub argument
-v, --od1.od0.verbosity
increase output verbosity
-nv, --od1.od0.no-verbosity
od2:
Second OptionDescription
--od2.before BEFORE Before
--od2.after AFTER After
od2.subtree:
Sub-Tree 2
--od2.subtree.str STR
string option 2
"""
parser = TiramisuCmdlineParser(get_config(json), 'prog.py', remove_empty_od=True)
f = StringIO()
with redirect_stdout(f):
parser.print_help()
assert f.getvalue() == output
def test_optiondescription_help_subtree(json):
output = """usage: prog.py [-h] --od2.subtree.str STR --od2.before BEFORE --od2.after
AFTER

View File

@ -47,6 +47,10 @@ def test_short(json):
parser = TiramisuCmdlineParser(config, 'prog.py')
parser.parse_args(['-l', 'a'])
assert config.value.dict() == output
#
assert config.option('list').value.get() == config.option('l').value.get()
assert config.option('list').owner.get() == config.option('l').owner.get()
assert config.option('list').owner.isdefault() == config.option('l').owner.isdefault()
def test_short_mandatory(json):