def testAddContentIfFileExists(self):
"""Tests if the editing of a file existing works."""
content = "this is test content. "
expected = content + content
with tempfile.TemporaryDirectory() as tmpdir:
source = os.path.join(tmpdir, self.file)
with open(source, "a") as f:
f.write(content)
handler = file_handler.FileHandler()
self.assertTrue(os.path.exists(source))
handler.AddContent(source, content)
self.assertTrue(os.path.exists(source))
with open(source, "r") as f:
actual = f.read()
self.assertEqual(expected, actual)
评论列表
文章目录