test_cli.py 文件源码

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

项目:BoerOPS 作者: BoerOPS 项目源码 文件源码
def test_parser(self):
        parser = cli._get_parser(gitlab.v3.cli)
        subparsers = None
        for action in parser._actions:
            if type(action) == argparse._SubParsersAction:
                subparsers = action
                break
        self.assertIsNotNone(subparsers)
        self.assertIn('user', subparsers.choices)

        user_subparsers = None
        for action in subparsers.choices['user']._actions:
            if type(action) == argparse._SubParsersAction:
                user_subparsers = action
                break
        self.assertIsNotNone(user_subparsers)
        self.assertIn('list', user_subparsers.choices)
        self.assertIn('get', user_subparsers.choices)
        self.assertIn('delete', user_subparsers.choices)
        self.assertIn('update', user_subparsers.choices)
        self.assertIn('create', user_subparsers.choices)
        self.assertIn('block', user_subparsers.choices)
        self.assertIn('unblock', user_subparsers.choices)

        actions = user_subparsers.choices['create']._option_string_actions
        self.assertFalse(actions['--twitter'].required)
        self.assertTrue(actions['--username'].required)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号