Skip to content

Comments

[MNT] Replace live server calls with mocks in test_clustering_task.py#1669

Open
Shafwansafi06 wants to merge 7 commits intoopenml:mainfrom
Shafwansafi06:fix-1649-clustering-mocks
Open

[MNT] Replace live server calls with mocks in test_clustering_task.py#1669
Shafwansafi06 wants to merge 7 commits intoopenml:mainfrom
Shafwansafi06:fix-1649-clustering-mocks

Conversation

@Shafwansafi06
Copy link

Metadata:

Details:

  • Resolved Environment Issue: Fixed a ValueError related to hydra-core and Python 3.13 incompatibility by upgrading hydra-core to version 1.3.2.
  • Mocked test_get_dataset: Replaced live server call with a mock.
  • Mocked test_download_task: Correctly mocked get_task in the base class to ensure the mock is picked up during super() calls.
  • Mocked test_upload_task: Mocked create_task and the publish method, removing network dependencies.

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

Copilot AI review requested due to automatic review settings February 20, 2026 06:10
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_task usage in test_get_dataset to avoid production server dependency.
  • Mock get_task at the base-test import site to ensure super() calls pick up the mock in test_download_task.
  • Mock openml.tasks.create_task (and related behavior) in test_upload_task to 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>
Copilot AI review requested due to automatic review settings February 20, 2026 06:16
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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>
Copilot AI review requested due to automatic review settings February 20, 2026 06:19
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment on lines +32 to 35

task = openml.tasks.get_task(self.task_id)
task.get_dataset()

Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@Shafwansafi06
Copy link
Author

@amueller can you review this PR and check for the issues my Tests has passed in local machine (Ubuntu 24 LTS)

@Shafwansafi06
Copy link
Author

@copilot open a new pull request to apply changes based on the comments in this thread

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MNT] Replace Live Server Calls with Mocks in Unit Tests

1 participant