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
@@ -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 ):
You can’t perform that action at this time.
0 commit comments