def test_add_command(self):
     app = Application()
     def target(one, two='foo'):
         return 'target called: %s %s' % (one, two)
     app.add_command(target=target)
     res = app.run(args=['target', 'ooonnneee', '--two', 'tttwwwooo'])
     assert 'target called: ooonnneee tttwwwooo' in res
 def test_add_option(self):
     app = Application()
     app.add_option('afoobar')
     assert 'afoobar' in app.usage
     app.add_option('-b', '--bfoobar', dest='bfb')
     assert '-b' in app.usage
     assert '--bfoobar BFB' in app.usage
示例#3
0
    def test_command_decorator(self):
        app = Application('myapp')

        @app.command
        def target():
            return 'you have masterfully hit the target, old chap'

        app.run(args=['target'])
示例#4
0
    def test_add_command(self):
        app = Application()

        def target(one, two='foo'):
            return 'target called: %s %s' % (one, two)

        app.add_command(target=target)
        res = app.run(args=['target', 'ooonnneee', '--two', 'tttwwwooo'])
        assert 'target called: ooonnneee tttwwwooo' in res
示例#5
0
 def test_add_option(self):
     app = Application()
     app.add_option('afoobar')
     assert 'afoobar' in app.usage
     app.add_option('-b', '--bfoobar', dest='bfb')
     assert '-b' in app.usage
     assert '--bfoobar BFB' in app.usage
 def test_command_decorator(self):
     app = Application('myapp')
     @app.command
     def target():
         return 'you have masterfully hit the target, old chap'
     app.run(args=['target'])
 def test_run(self):
     app = Application()
     args = ['-h']
     res = app.run(args=args)
示例#8
0
 def test_creation(self):
     app = Application()
     assert 'nosetests' in app.name, 'nosetests not in %s' % app.name
     app = Application('foobar')
     assert 'foobar' in app.name, 'foobar not in %s' % app.name
示例#9
0
 def test_run(self):
     app = Application()
     args = ['-h']
     res = app.run(args=args)
示例#10
0
 def test_usage(self):
     app = Application('foobarapp')
     assert 'foobarapp' in app.usage
     assert '-h' in app.usage
示例#11
0
 def test_parser(self):
     app = Application()
     assert app.parser
     assert app.parser.prog == app.name