Skip to content
Merged
Changes from 2 commits
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
15 changes: 9 additions & 6 deletions tests/test_tasks/test_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import inspect
import os
import shutil
import tempfile
from pathlib import Path

import numpy as np
Expand All @@ -18,8 +20,7 @@ class OpenMLSplitTest(TestBase):
def setUp(self):
__file__ = inspect.getfile(OpenMLSplitTest)
self.directory = os.path.dirname(__file__)
# This is for dataset
self.arff_filepath = (
source_arff = (
Path(self.directory).parent
/ "files"
/ "org"
Expand All @@ -29,13 +30,15 @@ def setUp(self):
/ "1882"
/ "datasplits.arff"
)
self.pd_filename = self.arff_filepath.with_suffix(".pkl.py3")
# Use temporary directory to avoid conflicts with other tests
self.temp_dir = Path(tempfile.mkdtemp())
Comment thread
omkar-334 marked this conversation as resolved.
Outdated
self.arff_filepath = self.temp_dir / "datasplits.arff"
shutil.copy2(source_arff, self.arff_filepath)
Comment thread
omkar-334 marked this conversation as resolved.
Outdated

def tearDown(self):
try:
os.remove(self.pd_filename)
except (OSError, FileNotFoundError):
# Replaced bare except. Not sure why these exceptions are acceptable.
shutil.rmtree(self.temp_dir, ignore_errors=True)
except OSError:
pass
Comment on lines 42 to 45
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The try/except block wrapping shutil.rmtree with ignore_errors=True is redundant. When ignore_errors=True is set, shutil.rmtree already suppresses all exceptions internally, making the outer try/except OSError unnecessary. Consider simplifying to just: shutil.rmtree(self.temp_dir, ignore_errors=True)

Copilot uses AI. Check for mistakes.

def test_eq(self):
Expand Down