Skip to content

Commit 26d341e

Browse files
authored
Merge branch 'main' into doc/add-usage-examples-to-core-docstrings
2 parents 49bd8db + dbd432c commit 26d341e

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

tests/test_tasks/test_split.py

Lines changed: 10 additions & 3 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
@@ -19,7 +21,7 @@ def setUp(self):
1921
__file__ = inspect.getfile(OpenMLSplitTest)
2022
self.directory = os.path.dirname(__file__)
2123
# This is for dataset
22-
self.arff_filepath = (
24+
source_arff = (
2325
Path(self.directory).parent
2426
/ "files"
2527
/ "org"
@@ -29,13 +31,18 @@ def setUp(self):
2931
/ "1882"
3032
/ "datasplits.arff"
3133
)
34+
# Use a unique temp directory for each test to avoid race conditions
35+
# when running tests in parallel (see issue #1641)
36+
self._temp_dir = tempfile.TemporaryDirectory()
37+
self.arff_filepath = Path(self._temp_dir.name) / "datasplits.arff"
38+
shutil.copy(source_arff, self.arff_filepath)
3239
self.pd_filename = self.arff_filepath.with_suffix(".pkl.py3")
3340

3441
def tearDown(self):
42+
# Clean up the entire temp directory
3543
try:
36-
os.remove(self.pd_filename)
44+
self._temp_dir.cleanup()
3745
except (OSError, FileNotFoundError):
38-
# Replaced bare except. Not sure why these exceptions are acceptable.
3946
pass
4047

4148
def test_eq(self):

0 commit comments

Comments
 (0)