Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: use TemporaryDirectory instead of mkdtemp
Replace tempfile.mkdtemp() with tempfile.TemporaryDirectory() for
safer automatic cleanup, as suggested by @geetu040.
  • Loading branch information
Alm0stSurely committed Feb 20, 2026
commit 8910a81db855948485a38da49b1868748f506ba0
6 changes: 3 additions & 3 deletions tests/test_tasks/test_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ def setUp(self):
)
# Use a unique temp directory for each test to avoid race conditions
# when running tests in parallel (see issue #1641)
self._temp_dir = tempfile.mkdtemp()
self.arff_filepath = Path(self._temp_dir) / "datasplits.arff"
self._temp_dir = tempfile.TemporaryDirectory()
self.arff_filepath = Path(self._temp_dir.name) / "datasplits.arff"
shutil.copy(source_arff, self.arff_filepath)
self.pd_filename = self.arff_filepath.with_suffix(".pkl.py3")

def tearDown(self):
# Clean up the entire temp directory
try:
shutil.rmtree(self._temp_dir)
self._temp_dir.cleanup()
except (OSError, FileNotFoundError):
pass
Comment thread
fkiraly marked this conversation as resolved.

Expand Down