[MNT] Replace live server calls with mocks in test_clustering_task.py#1669
[MNT] Replace live server calls with mocks in test_clustering_task.py#1669Shafwansafi06 wants to merge 7 commits intoopenml:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the clustering task unit tests to avoid live OpenML server interactions by replacing network-dependent calls with mocks, aligning with the goal of keeping these as true unit tests (Fixes #1649).
Changes:
- Mock
openml.tasks.get_taskusage intest_get_datasetto avoid production server dependency. - Mock
get_taskat the base-test import site to ensuresuper()calls pick up the mock intest_download_task. - Mock
openml.tasks.create_task(and related behavior) intest_upload_taskto remove network/upload dependencies.
Comments suppressed due to low confidence (1)
tests/test_tasks/test_clustering_task.py:12
- These imports appear unused after switching the tests to mocks (e.g., pytest, OpenMLServerException, TestBase). Please remove unused imports to keep the test module minimal and avoid confusion about required fixtures/markers.
import pytest
import openml
from openml.exceptions import OpenMLServerException
from openml.tasks import TaskType
from openml.testing import TestBase
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| task = openml.tasks.get_task(self.task_id) | ||
| task.get_dataset() | ||
|
|
There was a problem hiding this comment.
There are two identical @mock.patch("tests.test_tasks.test_task.get_task") decorators applied to test_download_task, but the test function only accepts a single injected mock. This will raise a TypeError at runtime (extra argument). Remove the duplicate decorator (and the extra blank line) so only one patch is applied.
|
@amueller can you review this PR and check for the issues my Tests has passed in local machine (Ubuntu 24 LTS) |
|
@copilot open a new pull request to apply changes based on the comments in this thread |
Metadata:
Details:
Test Run Results:
tests/test_tasks/test_clustering_task.py::OpenMLClusteringTaskTest::test_download_task PASSED
tests/test_tasks/test_clustering_task.py::OpenMLClusteringTaskTest::test_get_dataset PASSED
tests/test_tasks/test_clustering_task.py::OpenMLClusteringTaskTest::test_upload_task PASSED
3 Passed in 0.09s