Skip to content

Commit 9674d19

Browse files
committed
Keep bugfix from main
1 parent 39c73d1 commit 9674d19

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

tests/test_tasks/test_split.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
import inspect
55
import os
6+
import shutil
7+
import tempfile
68
from pathlib import Path
79

810
import numpy as np
@@ -18,8 +20,7 @@ class OpenMLSplitTest(TestBase):
1820
def setUp(self):
1921
__file__ = inspect.getfile(OpenMLSplitTest)
2022
self.directory = os.path.dirname(__file__)
21-
# This is for dataset
22-
self.arff_filepath = (
23+
source_arff = (
2324
Path(self.directory).parent
2425
/ "files"
2526
/ "org"
@@ -29,13 +30,18 @@ def setUp(self):
2930
/ "1882"
3031
/ "datasplits.arff"
3132
)
33+
# Use a unique temp directory for each test to avoid race conditions
34+
# when running tests in parallel (see issue #1641)
35+
self._temp_dir = tempfile.TemporaryDirectory()
36+
self.arff_filepath = Path(self._temp_dir.name) / "datasplits.arff"
37+
shutil.copy(source_arff, self.arff_filepath)
3238
self.pd_filename = self.arff_filepath.with_suffix(".pkl.py3")
3339

3440
def tearDown(self):
41+
# Clean up the entire temp directory
3542
try:
36-
os.remove(self.pd_filename)
43+
self._temp_dir.cleanup()
3744
except (OSError, FileNotFoundError):
38-
# Replaced bare except. Not sure why these exceptions are acceptable.
3945
pass
4046

4147
def test_eq(self):

0 commit comments

Comments
 (0)