test_main.py 文件源码

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

项目:aws-ec2rescue-linux 作者: awslabs 项目源码 文件源码
def test_main_help_class(self, main_log_handler_mock, mkdir_mock):
        """Test help output for a class of modules."""
        path_to_ec2rl = os.path.abspath("ec2rl")
        test_path = os.path.sep.join([os.path.split(path_to_ec2rl)[0], "test", "modules", "ec2rl"])
        sys.argv = [test_path, "help", "--only-classes=diagnose,asdf"]
        ec2rl = ec2rlcore.main.Main(full_init=True)

        with contextlib.redirect_stdout(self.output):
            self.assertTrue(ec2rl.help())

        # Check that the length of the help message matches the expected value
        self.assertEqual(len(self.output.getvalue()), 1777)
        self.assertTrue(self.output.getvalue().startswith("arpcache:\nDetermines if aggressive arp caching is enabled"))
        self.assertTrue(self.output.getvalue().endswith("ackets to drop due to discarded skbs\nRequires sudo: False\n"))
        self.assertTrue(main_log_handler_mock.called)
        self.assertTrue(mkdir_mock.called)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号