示例#1
0
def test_pos_2():
    @annotations(test_code=Pos("Test code (default {default})", 't'))
    def func(test_code='1234'):
        for i in (1, 2, 3):
            yield test_code

    call(func, arg_list=[])
示例#2
0
文件: test_core.py 项目: swayf/pyclap
def test_pos_2():
    @annotations(test_code=Pos("Test code (default {default})", 't'))
    def func(test_code='1234'):
        for i in (1,2,3):
           yield test_code

    call(func, arg_list=[])
示例#3
0
文件: test_core.py 项目: swayf/pyclap
def test_output_4():
    @annotations(test2_arg=Pos("test2 help message"),
                 test2_code=Opt("Test code (default {default})", 't', choices=('test_1','test_2','test_3')))
    def func(test2_arg, test2_code='test_1'):
        return test2_arg, test2_code

    call(func, arg_list=[])
示例#4
0
文件: test_core.py 项目: swayf/pyclap
def test_output_2():
    @annotations(test_pos=Pos("test2 help message"),
                 test_opt_1=Opt("Test help (default {default})", 't'),
                 test_opt_2=Flag("Test help 2"))
    def func(test_pos, test_opt_1='1234', test_opt_2=False):
        pass

    call(func, arg_list=['-h'])
示例#5
0
def test_output_3():
    @annotations(test2_arg=Pos("test2 help message",
                               choices=('test_1', 'test_2', 'test_3')),
                 test2_code=Opt("Test code (default {default})", 't'))
    def func(test2_arg, test2_code='1234'):
        return test2_arg, test2_code

    call(func, arg_list=[])
示例#6
0
文件: test_core.py 项目: swayf/pyclap
def test_output_5():
    @annotations(test_pos=Pos(),
                 test_opt_1=Opt(abbrev='t'),
                 test_opt_2=Flag())
    def func(test_pos, test_opt_1='1234', test_opt_2=False):
        pass

    call(func, arg_list=['-h'])
示例#7
0
def test_output_2():
    @annotations(test_pos=Pos("test2 help message"),
                 test_opt_1=Opt("Test help (default {default})", 't'),
                 test_opt_2=Flag("Test help 2"))
    def func(test_pos, test_opt_1='1234', test_opt_2=False):
        pass

    call(func, arg_list=['-h'])
示例#8
0
文件: test_core.py 项目: swayf/pyclap
def test_pos_1():
    @annotations(test_code=Pos("Test code (default {default})"))
    def func(test_code='1234'):
        for i in (1,2,3):
           yield test_code

    ns, output = call(func, arg_list=[])
    eq_(ns['test_code'], '1234')
    eq_(output, ['1234','1234','1234'])

    ns, output = call(func, arg_list=['4321'])
    eq_(ns['test_code'], '4321')
    eq_(output, ['4321','4321','4321'])
示例#9
0
def test_pos_1():
    @annotations(test_code=Pos("Test code (default {default})"))
    def func(test_code='1234'):
        for i in (1, 2, 3):
            yield test_code

    ns, output = call(func, arg_list=[])
    eq_(ns['test_code'], '1234')
    eq_(output, ['1234', '1234', '1234'])

    ns, output = call(func, arg_list=['4321'])
    eq_(ns['test_code'], '4321')
    eq_(output, ['4321', '4321', '4321'])
示例#10
0
def test_interface_2():
    class Interface(object):
        commands = ['search']

        def __init__(self):
            self.result = ' 5555 '

        @annotations(regex=Pos("Regular Expression"),
                     test_flag=Flag("Flag", "f"))
        def search(self, regex, test_flag=False):
            return self.result + regex, test_flag

    call(Interface(), arg_list=['search', '-f'])
示例#11
0
文件: test_core.py 项目: swayf/pyclap
def test_interface_2():

    class Interface(object):
        commands=['search']
        def __init__(self):
            self.result = ' 5555 '

        @annotations(regex=Pos("Regular Expression"),
                     test_flag=Flag("Flag","f"))
        def search(self, regex, test_flag=False):
            return self.result + regex, test_flag


    call(Interface(), arg_list=['search', '-f'])
示例#12
0
文件: test_core.py 项目: swayf/pyclap
def test_obj_interface_1():
    class Interface(object):
        commands=['search']
        def __init__(self):
            self.result = ' 5555 '

        @annotations(regex=Pos("Regular Expression"))
        def search(self, regex):
            return self.result + regex

    ns, output = call(Interface(), arg_list=['search', 'test'])
    eq_(output[0], ' 5555 test')
示例#13
0
def test_obj_interface_1():
    class Interface(object):
        commands = ['search']

        def __init__(self):
            self.result = ' 5555 '

        @annotations(regex=Pos("Regular Expression"))
        def search(self, regex):
            return self.result + regex

    ns, output = call(Interface(), arg_list=['search', 'test'])
    eq_(output[0], ' 5555 test')
示例#14
0
def test_arg_1():
    ns, output = call(arg_list=['command1', '1234'])
    eq_(ns['_cmd_name_'], 'command1')
    eq_(ns['positional_arg'], '1234')
    eq_(ns['optional_arg'], 'test')
示例#15
0
def test_arg_1():
    ns, output = call(arg_list=['command1','1234'])
    eq_(ns['_cmd_name_'], 'command1')
    eq_(ns['positional_arg'], '1234')
    eq_(ns['optional_arg'], 'test')
示例#16
0
def test_doc_2():
    call(arg_list=['-h'])
示例#17
0
def test_doc_2():
    call(arg_list=['-h'])
示例#18
0
def test_output_5():
    @annotations(test_pos=Pos(), test_opt_1=Opt(abbrev='t'), test_opt_2=Flag())
    def func(test_pos, test_opt_1='1234', test_opt_2=False):
        pass

    call(func, arg_list=['-h'])
示例#19
0
def test_doc_1():
    call(arg_list=[])
示例#20
0
def test_doc_1():
    call(arg_list=[])