File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44import inspect
55import os
6+ import shutil
7+ import tempfile
68from pathlib import Path
79
810import 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 ):
You can’t perform that action at this time.
0 commit comments