test_commands.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:rcli 作者: contains-io 项目源码 文件源码
def test_custom_primary_command(create_project, run):
    """Test creating a command that overwrites the primary command."""
    usage = '''
        Usage: hello [--name <name>]

        Options:
          --name <name>  The name to print [default: world].
        '''
    with create_project('''
        def hello(name):
            """{usage}"""
            print('Hello, {{name}}!'.format(name=name))
    '''.format(usage=usage)):
        assert run('hello --name everyone') == 'Hello, everyone!\n'
        assert run('hello') == 'Hello, world!\n'
        assert inspect.cleandoc(run('hello -h')) == inspect.cleandoc(usage)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号