Test arg parse
This commit is contained in:
parent
41768d9616
commit
8a0fc13f23
|
@ -54,7 +54,7 @@ tray_icon_size = None
|
||||||
temp = tempfile.NamedTemporaryFile(prefix="Solaar_", mode="w", delete=True)
|
temp = tempfile.NamedTemporaryFile(prefix="Solaar_", mode="w", delete=True)
|
||||||
|
|
||||||
|
|
||||||
def _parse_arguments():
|
def create_parser():
|
||||||
arg_parser = argparse.ArgumentParser(
|
arg_parser = argparse.ArgumentParser(
|
||||||
prog=NAME.lower(), epilog="For more information see https://pwr-solaar.github.io/Solaar"
|
prog=NAME.lower(), epilog="For more information see https://pwr-solaar.github.io/Solaar"
|
||||||
)
|
)
|
||||||
|
@ -99,7 +99,11 @@ def _parse_arguments():
|
||||||
choices=cli.actions,
|
choices=cli.actions,
|
||||||
help="command-line action to perform (optional); append ' --help' to show args",
|
help="command-line action to perform (optional); append ' --help' to show args",
|
||||||
)
|
)
|
||||||
|
return arg_parser
|
||||||
|
|
||||||
|
|
||||||
|
def _parse_arguments():
|
||||||
|
arg_parser = create_parser()
|
||||||
args = arg_parser.parse_args()
|
args = arg_parser.parse_args()
|
||||||
|
|
||||||
if args.help_actions:
|
if args.help_actions:
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
from solaar.gtk import create_parser
|
||||||
|
|
||||||
|
|
||||||
|
def test_arg_parse():
|
||||||
|
parser = create_parser()
|
||||||
|
res = parser.parse_args([])
|
||||||
|
|
||||||
|
assert res.debug == 0
|
||||||
|
assert res.hidraw_path is None
|
||||||
|
assert res.restart_on_wake_up is False
|
||||||
|
assert res.window is None
|
||||||
|
assert res.battery_icons is None
|
||||||
|
assert res.tray_icon_size is None
|
||||||
|
|
||||||
|
|
||||||
|
def test_arg_parse_debug():
|
||||||
|
parser = create_parser()
|
||||||
|
res = parser.parse_args(["--debug"])
|
||||||
|
|
||||||
|
assert res.debug == 1
|
||||||
|
|
||||||
|
|
||||||
|
def test_arg_parse_version():
|
||||||
|
parser = create_parser()
|
||||||
|
res = parser.parse_args(["version"])
|
||||||
|
|
||||||
|
assert res
|
Loading…
Reference in New Issue