示例#1
0
文件: test_cli.py 项目: jaredly/pm
def test_argdict_exclude(parser):
    '''You can add a mutually exclusive pair'''
    cli.add_argdict(parser, {'exclude':[
        {'options':['--foo'], 'dest':'foo', 'default':True},
        {'options':['--bar'], 'dest':'bar', 'default':True}
    ]})
    parses(parser, ['--foo', 'what'], {'foo':'what'})
    parses(parser, ['--bar', 'what'], {'bar':'what'})
    with pytest.raises(SystemExit):
        parser.parse_args(['--foo', 'what', '--bar', 'other'])
    parser.parse_args([])
示例#2
0
文件: test_cli.py 项目: jaredly/pm
def test_argdict_baddict(parser):
    '''You need one of those three signatures'''
    with pytest.raises(ValueError):
        cli.add_argdict(parser, {'foo':'bar'})
示例#3
0
文件: test_cli.py 项目: jaredly/pm
def test_argdict_option(parser):
    '''You can add an option'''
    cli.add_argdict(parser, {'options':['-m', '--man'], 'dest':'man'})
    parses(parser, ['-m', 'sad'], {'man':'sad'})
    parser.parse_args([])
示例#4
0
文件: test_cli.py 项目: jaredly/pm
def test_argdict_option_required(parser):
    '''You can add an option'''
    cli.add_argdict(parser, {'options':['-m', '--man'], 'dest':'man', 'required':True})
    parses(parser, ['-m', 'sad'], {'man':'sad'})
    with pytest.raises(SystemExit):
        parser.parse_args([])
示例#5
0
文件: test_cli.py 项目: jaredly/pm
def test_argdict_normal(parser):
    '''You can add a normal argument'''
    cli.add_argdict(parser, {'dest': 'man'})
    parses(parser, ['fun'], {'man':'fun'})
    with pytest.raises(SystemExit):
        parser.parse_args([])