Exemplo n.º 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=[])
Exemplo n.º 2
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=[])
Exemplo n.º 3
0
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=[])
Exemplo n.º 4
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'])
Exemplo n.º 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=[])
Exemplo n.º 6
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'])
Exemplo n.º 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'])
Exemplo n.º 8
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'])
Exemplo n.º 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'])
Exemplo n.º 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'])
Exemplo n.º 11
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'])
Exemplo n.º 12
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')
Exemplo n.º 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')
Exemplo n.º 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')
Exemplo n.º 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')
Exemplo n.º 16
0
def test_doc_2():
    call(arg_list=['-h'])
Exemplo n.º 17
0
def test_doc_2():
    call(arg_list=['-h'])
Exemplo n.º 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'])
Exemplo n.º 19
0
def test_doc_1():
    call(arg_list=[])
Exemplo n.º 20
0
def test_doc_1():
    call(arg_list=[])