23 lines
613 B
Python
23 lines
613 B
Python
import os
|
|
import pathlib
|
|
import sys
|
|
import tempfile
|
|
import unittest
|
|
|
|
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
|
|
|
from failure import Failure
|
|
from text_files import file_writes
|
|
|
|
|
|
class ReplaceFile(unittest.TestCase):
|
|
def test_removes_what_it_staged_when_the_replace_fails(self):
|
|
with tempfile.TemporaryDirectory() as root:
|
|
os.mkdir(os.path.join(root, "in-the-way"))
|
|
self.assertEqual(file_writes.replace_file(pathlib.Path(root, "in-the-way"), b"data"), Failure("Is a directory"))
|
|
self.assertEqual(os.listdir(root), ["in-the-way"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|