Skip to content

Comments

[MNT] Replace live server calls with mocks in test_task_methods.py#1664

Open
Sandipmandal25 wants to merge 1 commit intoopenml:mainfrom
Sandipmandal25:mnt/mock-test-task-methods
Open

[MNT] Replace live server calls with mocks in test_task_methods.py#1664
Sandipmandal25 wants to merge 1 commit intoopenml:mainfrom
Sandipmandal25:mnt/mock-test-task-methods

Conversation

@Sandipmandal25
Copy link

@Sandipmandal25 Sandipmandal25 commented Feb 19, 2026

Metadata

Details

Both tests in OpenMLTaskMethodsTest previously required a running test server. This PR removes those dependencies:

  • test_tagging — patches requests.Session.post to return mock XML responses for task/tag and task/untag endpoints; asserts the HTTP call was made with the correct URL, data, and headers via mock_post.assert_called_once_with(...). No network calls required.

  • test_get_train_and_test_split_indices — uses the static cache (task 1882 + dataset 2 already present); no network calls. Also modernises assertRaisesRegexpytest.raises for consistency with the rest of the test suite.

Test Run

platform darwin -- Python 3.13.3, pytest-9.0.2
tests/test_tasks/test_task_methods.py::OpenMLTaskMethodsTest::test_get_train_and_test_split_indices PASSED
tests/test_tasks/test_task_methods.py::OpenMLTaskMethodsTest::test_tagging PASSED

2 passed in 0.25s

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 removes live test server dependencies from two tests in test_task_methods.py by replacing them with appropriate mocks. The changes align with the broader initiative (issue #1649) to convert integration tests into proper unit tests that don't rely on external server availability.

Changes:

  • Removed @pytest.mark.test_server() decorators from both tests
  • Replaced live server calls with mocks in test_tagging using stateful simulation
  • Migrated assertRaisesRegex to pytest.raises in test_get_train_and_test_split_indices

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Sandipmandal25 Sandipmandal25 force-pushed the mnt/mock-test-task-methods branch from 7ed00d4 to 7e95001 Compare February 20, 2026 06:16
@Sandipmandal25 Sandipmandal25 force-pushed the mnt/mock-test-task-methods branch from 7e95001 to 51705d1 Compare February 20, 2026 10:11
Copilot AI review requested due to automatic review settings February 20, 2026 10:11
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.

@Sandipmandal25 Sandipmandal25 force-pushed the mnt/mock-test-task-methods branch from 51705d1 to 9ab236e Compare February 20, 2026 11:28
Copilot AI review requested due to automatic review settings February 20, 2026 12:51
@Sandipmandal25 Sandipmandal25 force-pushed the mnt/mock-test-task-methods branch from 9ab236e to aac0ad8 Compare February 20, 2026 12:51
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.

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

2 participants