Skip to content

Commit

Permalink
PEP8
Browse files Browse the repository at this point in the history
  • Loading branch information
liamhuber committed May 28, 2024
1 parent f7ebb91 commit 603fe61
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions tests/unit/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def test_file_instantiation(self):
else:
self.assertRaises(ValueError, FileObject, "/test.txt", "test")


def test_directory_exists(self):
self.assertTrue(Path("test").exists() and Path("test").is_dir())

Expand Down Expand Up @@ -122,26 +121,25 @@ def test_remove(self):
)

def test_copy(self):
f = FileObject("test_copy.txt", self.directory)
f.write("sam wrote this wondrful thing")
new_file_1 = f.copy("another_test")
self.assertEqual(new_file_1.read(), "sam wrote this wondrful thing")
new_file_2 = f.copy("another_test", ".")
with open("another_test", "r") as file:
txt = file.read()
self.assertEqual(txt, "sam wrote this wondrful thing")
new_file_2.delete() # needed because current directory
new_file_3 = f.copy(str(f.path.parent / "another_test"), ".")
self.assertEqual(new_file_1.path.absolute(), new_file_3.path.absolute())
new_file_4 = f.copy(directory=".")
with open("test_copy.txt", "r") as file:
txt = file.read()
self.assertEqual(txt, "sam wrote this wondrful thing")
new_file_4.delete() # needed because current directory
with self.assertRaises(ValueError):
f = FileObject("test_copy.txt", self.directory)
f.write("sam wrote this wondrful thing")
new_file_1 = f.copy("another_test")
self.assertEqual(new_file_1.read(), "sam wrote this wondrful thing")
new_file_2 = f.copy("another_test", ".")
with open("another_test", "r") as file:
txt = file.read()
self.assertEqual(txt, "sam wrote this wondrful thing")
new_file_2.delete() # needed because current directory
new_file_3 = f.copy(str(f.path.parent / "another_test"), ".")
self.assertEqual(new_file_1.path.absolute(), new_file_3.path.absolute())
new_file_4 = f.copy(directory=".")
with open("test_copy.txt", "r") as file:
txt = file.read()
self.assertEqual(txt, "sam wrote this wondrful thing")
new_file_4.delete() # needed because current directory
with self.assertRaises(ValueError):
f.copy()


def test_str(self):
f = FileObject("test_copy.txt", self.directory)
if platform.system() == "Windows":
Expand All @@ -150,5 +148,6 @@ def test_str(self):
txt = f"my file: {self.directory.path.absolute()}/test_copy.txt"
self.assertEqual(f"my file: {f}", txt)


if __name__ == '__main__':
unittest.main()

0 comments on commit 603fe61

Please sign in to comment.