Skip to content

Commit

Permalink
Fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mkennard-aquaveo committed Dec 6, 2023
1 parent 6f7aadf commit 9cc9324
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions _package/tests/unit_tests/filesystem_pyt.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,15 @@ def test_clear_folder(self):
# Test using str
d = tempfile.mkdtemp()
temp_file = tempfile.NamedTemporaryFile(mode='wt', dir=d)
assert Path(temp_file).is_file()
assert Path(temp_file.name).is_file()
clear_folder(d)
assert not Path(temp_file).is_file()
assert not Path(temp_file.name).is_file()

# Test using pathlib
temp_file = tempfile.NamedTemporaryFile(mode='wt', dir=d)
assert Path(temp_file).is_file()
assert Path(temp_file.name).is_file()
clear_folder(Path(d))
assert not Path(temp_file).is_file()
assert not Path(temp_file.name).is_file()

shutil.rmtree(d)

Expand All @@ -181,9 +181,9 @@ def test_make_or_clear_dir(self):
make_or_clear_dir(path)
assert Path(path).is_dir()
temp_file = tempfile.NamedTemporaryFile(mode='wt', dir=path)
assert Path(temp_file).is_file()
assert Path(temp_file.name).is_file()
make_or_clear_dir(path)
assert not Path(temp_file).is_file()
assert not Path(temp_file.name).is_file()
assert Path(path).is_dir()
Path(path).unlink()

Expand All @@ -193,9 +193,9 @@ def test_make_or_clear_dir(self):
make_or_clear_dir(path)
assert path.is_dir()
temp_file = tempfile.NamedTemporaryFile(mode='wt', dir=path)
assert Path(temp_file).is_file()
assert Path(temp_file.name).is_file()
make_or_clear_dir(path)
assert not Path(temp_file).is_file()
assert not Path(temp_file.name).is_file()
assert path.is_dir()
path.unlink()

Expand All @@ -219,7 +219,7 @@ def test_copyfile(self):
# Test using str
d = tempfile.mkdtemp()
temp_file = tempfile.NamedTemporaryFile(mode='wt', dir=d)
with Path(temp_file).open('w') as file:
with Path(temp_file.name).open('w') as file:
file.write('bob')
temp_file_copy = os.path.join(d, 'copy')
copyfile(temp_file, temp_file_copy)
Expand All @@ -229,30 +229,30 @@ def test_copyfile(self):
# Test using pathlib
d = tempfile.mkdtemp()
temp_file = tempfile.NamedTemporaryFile(mode='wt', dir=d)
with Path(temp_file).open('w') as file:
with Path(temp_file.name).open('w') as file:
file.write('bob')
temp_file_copy = os.path.join(d, 'copy')
copyfile(Path(temp_file), Path(temp_file_copy))
copyfile(Path(temp_file.name), Path(temp_file_copy))
assert filecmp.cmp(temp_file, temp_file_copy)
shutil.rmtree(d)

def test_removefile(self):
"""Tests filesystem.removefile()."""
# Test using str
temp_file = tempfile.NamedTemporaryFile(mode='wt')
assert Path(temp_file).is_file()
assert Path(temp_file.name).is_file()
removefile(temp_file)
assert Path(temp_file).is_file()
assert Path(temp_file.name).is_file()

# Test using pathlib
temp_file = tempfile.NamedTemporaryFile(mode='wt')
assert Path(temp_file).is_file()
removefile(Path(temp_file))
assert Path(temp_file).is_file()
assert Path(temp_file.name).is_file()
removefile(Path(temp_file.name))
assert Path(temp_file.name).is_file()

def test_is_somewhere_below_system_temp(self):
"""Tests filesystem.is_somewhere_below_system_temp()."""
temp_file = tempfile.NamedTemporaryFile(mode='wt')
self.assertTrue(True, is_somewhere_below_system_temp(temp_file))
self.assertTrue(True, is_somewhere_below_system_temp(Path(temp_file)))
Path(temp_file).unlink()
self.assertTrue(True, is_somewhere_below_system_temp(Path(temp_file.name)))
Path(temp_file.name).unlink()

0 comments on commit 9cc9324

Please sign in to comment.