test_main.py 文件源码

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

项目:aws-ec2rescue-linux 作者: awslabs 项目源码 文件源码
def test_main_main_software_check_no_missing_software(self,
                                                          main_log_handler_mock,
                                                          debug_log_handler_mock,
                                                          mkdir_mock,
                                                          which_mock):
        """Test that software_check returns the expected list of software."""
        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, "run"]
        ec2rl_softwarecheck_test = ec2rlcore.main.Main(debug=True, full_init=True)
        module_path = os.path.join(self.callpath, "test/modules/test_main_multi_run_prunemodules_fakeexecutable/")
        ec2rl_softwarecheck_test._modules = ec2rlcore.moduledir.ModuleDir(module_path)
        ec2rl_softwarecheck_test._modules.validate_constraints_have_args(options=ec2rl_softwarecheck_test.options,
                                                                         constraint=ec2rl_softwarecheck_test.constraint,
                                                                         without_keys=["software", "distro", "sudo"])
        with contextlib.redirect_stdout(self.output):
            self.assertTrue(ec2rl_softwarecheck_test.software_check())
        self.assertEqual("All test software requirements have been met.\n", self.output.getvalue())

        self.assertTrue(main_log_handler_mock.called)
        self.assertTrue(debug_log_handler_mock.called)
        self.assertTrue(mkdir_mock.called)
        self.assertTrue(which_mock.called)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号