Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def test_parseable():
parser = ArgumentPasserParser()
parser.add_optional_bool('-n')
parser.add_optional_bool('--rm')
parser.add_optional_bool('--detach')
parser.add_optional_bool('--interactive')
parser.add_argument('image')
parser.add_argument('command', nargs=argparse.REMAINDER)
args = parser.parse_args(['--interactive',
'--rm', 'true',
'-e', 'TEST1=1',
'-e', 'TEST2=2',
'--detach', 'false',
'--something', 'else',
'my.image',
'echo', '-n', 'hello', 'world'])
assert args['--something'] == 'else'
assert args['image'] == 'my.image'
assert args['command'] == ['echo', '-n', 'hello', 'world']
assert not args.get('-n')
assert args['--rm']
assert args['--interactive']
assert not args['--detach']
assert args.all_values('-e') == ['TEST1=1', 'TEST2=2']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.