Skip to content

Commit

Permalink
Merge pull request #1556 from pyiron/revert-1555-change_test
Browse files Browse the repository at this point in the history
Revert "[patch] Use `tempfile` instead of creating a directory"
  • Loading branch information
samwaseda authored Jul 29, 2024
2 parents e70de26 + 4065341 commit 0655277
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions tests/unit/archiving/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from pandas._testing import assert_frame_equal
from filecmp import dircmp
import shutil
import tempfile
from pyiron_base._tests import PyironTestCase, ToyJob


Expand Down Expand Up @@ -75,23 +74,23 @@ def test_content(self):
self.assertEqual(len(compare_obj.diff_files), 0)

def test_export_with_targz_extension(self):
with tempfile.TemporaryDirectory() as temp_dir:
tmp_path = os.path.abspath(os.path.join(os.curdir, temp_dir))
tar_arch = self.arch_dir_comp + ".tar.gz"
self.pr.pack(
destination_path=os.path.join(tmp_path, tar_arch),
csv_file_name=os.path.join(tmp_path, "exported.csv"),
compress=True,
)
desirable_lst = [tar_arch, "exported.csv"]
desirable_lst.sort()
content_tmp = os.listdir(tmp_path)
content_tmp.sort()
try:
shutil.rmtree(tmp_path)
except Exception as err_msg:
print(f"deleting unsuccessful: {err_msg}")
self.assertListEqual(desirable_lst, content_tmp)
os.makedirs(os.path.join(os.curdir, "tmp"))
tmp_path = os.path.abspath(os.path.join(os.curdir, "tmp"))
tar_arch = self.arch_dir_comp + ".tar.gz"
self.pr.pack(
destination_path=os.path.join(tmp_path, tar_arch),
csv_file_name=os.path.join(tmp_path, "exported.csv"),
compress=True,
)
desirable_lst = [tar_arch, "exported.csv"]
desirable_lst.sort()
content_tmp = os.listdir(tmp_path)
content_tmp.sort()
try:
shutil.rmtree(tmp_path)
except Exception as err_msg:
print(f"deleting unsuccessful: {err_msg}")
self.assertListEqual(desirable_lst, content_tmp)

@patch("os.makedirs")
@patch("shutil.copy2")
Expand Down

0 comments on commit 0655277

Please sign in to comment.