python 3.5 support

This commit is contained in:
2019-08-22 15:58:34 +02:00
parent 46866f1e38
commit ed54090710
3 changed files with 40 additions and 11 deletions

View File

@ -487,13 +487,13 @@ prog.py: error: unrecognized arguments: --int
def test_readme_cross_tree(json):
output = """usage: prog.py "none" [-h] [-v] [-nv] {str,list,int,none}
prog.py: error: unrecognized arguments: --int
prog.py: error: unrecognized arguments: --root.int
"""
parser = TiramisuCmdlineParser(get_config(json, True), 'prog.py')
f = StringIO()
with redirect_stderr(f):
try:
parser.parse_args(['none', '--int'])
parser.parse_args(['none', '--root.int'])
except SystemExit as err:
assert str(err) == "2"
else:
@ -503,13 +503,13 @@ prog.py: error: unrecognized arguments: --int
def test_readme_cross_tree_remove(json):
output = """usage: prog.py "none" [-h] [-v] [-nv]
prog.py: error: unrecognized arguments: --int
prog.py: error: unrecognized arguments: --root.int
"""
parser = TiramisuCmdlineParser(get_config(json, True), 'prog.py', display_modified_value=False)
f = StringIO()
with redirect_stderr(f):
try:
parser.parse_args(['none', '--int'])
parser.parse_args(['none', '--root.int'])
except SystemExit as err:
assert str(err) == "2"
else:
@ -859,3 +859,32 @@ def test_readme_longargument(json):
parser = TiramisuCmdlineParser(config, 'prog.py')
parser.parse_args(['list', '--list', 'a', '--v'])
assert config.value.dict() == output
def test_readme_unknown_key(json):
output1 = """usage: prog.py [-h] [-v] [-nv] {str,list,int,none}
prog.py: error: unrecognized arguments: --unknown
"""
output2 = """usage: prog.py [-h] [-v] [-nv] {str,list,int,none}
prog.py: error: unrecognized arguments: --root.unknown
"""
parser = TiramisuCmdlineParser(get_config(json, True), 'prog.py', fullpath=False)
f = StringIO()
with redirect_stderr(f):
try:
parser.parse_args(['--unknown'])
except SystemExit as err:
assert str(err) == "2"
else:
raise Exception('must raises')
assert f.getvalue() == output1
f = StringIO()
with redirect_stderr(f):
try:
parser.parse_args(['--root.unknown'])
except SystemExit as err:
assert str(err) == "2"
else:
raise Exception('must raises')
assert f.getvalue() == output2