test_utils.py 文件源码

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

项目:histonets-cv 作者: sul-cidr 项目源码 文件源码
def test_two_paired_options_to_argument_args(self):
        args = ['im', 't1', '-o', '1', 't2', '-a', '3', 't3']

        @click.command()
        @click.argument('img')
        @click.argument('arg', nargs=-1, required=True)
        @click.option('-o', '--option', multiple=True)
        @click.option('-a', '--another', multiple=True)
        @utils.pair_options_to_argument(
            'arg', {'option': 0, 'another': 1}, args=args, args_slice=(1, None)
        )
        def command(img, arg, option, another):
            click.echo(json.dumps((arg, option, another)))

        runner = CliRunner()
        output = runner.invoke(command, args).output
        assert 'Error' not in output
        assert ([["t1", "t2", "t3"], ["1", 0, 0], [1, "3", 1]]
                == json.loads(output))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号