test_file_handler.py 文件源码

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

项目:PlasoScaffolder 作者: ClaudiaSaxer 项目源码 文件源码
def testAddContentIfFileAndFolderDoesNotExist(self):
    """Tests if the method create or modify file with content works, if the
    file and Folder does not exist"""
    content = "this is test content. "
    expected = content

    with tempfile.TemporaryDirectory() as tmpdir:
      new_path = os.path.join(tmpdir, "newfolder")
      source = os.path.join(new_path, self.file)
      handler = file_handler.FileHandler()
      self.assertFalse(os.path.exists(source))
      handler.CreateOrModifyFileWithContent(source, content)
      self.assertTrue(os.path.exists(source))

      with open(source, "r") as f:
        actual = f.read()

    self.assertEqual(expected, actual)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号