示例#1
0
    def test1(self):
        result = UtilsCommand.call("is_str_in_file", "success", self.fp.name)
        self.assertEqual(result.code, 0)

        with self.assertRaises(CommandError):
            try:
                UtilsCommand.call("is_str_in_file", "fail", self.fp.name)
            except CommandError as error:
                self.assertNotEqual(error.result.code, 0)
                self.assertEqual(error.result.stderr, "")
                raise
示例#2
0
 def test3(self):
     open(self.dir_path, "w")
     UtilsCommand.call("make_sure_dir_exists", self.dir_path)
     self.assertTrue(module.os.path.isdir(self.dir_path))
     module.shutil.rmtree(self.dir_path)
示例#3
0
 def test1(self):
     self.assertFalse(module.os.path.exists(self.dir_path))
     UtilsCommand.call("make_sure_dir_exists", self.dir_path)
     self.assertTrue(module.os.path.isdir(self.dir_path))
     module.shutil.rmtree(self.dir_path)
示例#4
0
 def test2(self):
     with self.assertRaises(CommandError):
         UtilsCommand.call("is_line_in_file", "", self.fp.name)
示例#5
0
 def test3(self):
     module.os.mkdir(self.file_path)
     self.assertTrue(module.os.path.exists(self.file_path))
     UtilsCommand.call("make_sure_not_exists", self.file_path)
     self.assertFalse(module.os.path.exists(self.file_path))
示例#6
0
 def test2(self):
     open(self.file_path, "w")
     self.assertTrue(module.os.path.exists(self.file_path))
     UtilsCommand.call("make_sure_not_exists", self.file_path)
     self.assertFalse(module.os.path.exists(self.file_path))