openml-python icon indicating copy to clipboard operation
openml-python copied to clipboard

Migrate test_openml to pytest

Open anirudhsengar opened this issue 1 month ago • 0 comments

Metadata

  • Reference Issue: Part of https://github.com/openml/openml-python/issues/1252
  • New Tests Added: Yes (migrated existing tests to pytest style)
  • Documentation Updated: No
  • Change Log Entry: "Migrate tests/test_openml to pytest-style tests"

Details

  • This PR migrates all tests in test_openml from unittest.TestCase-based tests (openml.testing.TestBase) to pure pytest-style tests.
  • Files migrated:
    • test_api_calls.py: Converted TestConfig class to standalone pytest functions (test_too_long_uri, test_retry_on_database_error)
    • test_config.py: Converted TestConfig and TestConfigurationForExamples classes to standalone pytest functions
    • test_openml.py: Converted TestInit class to standalone pytest function (test_populate_cache)
  • Key changes:
    • Removed class wrappers inheriting from openml.testing.TestBase
    • Replaced unittest.skipIf with pytest.mark.skipif
    • Replaced self.assertRaisesRegex with pytest.raises context manager
    • Replaced self.assertDictEqual with plain assert statements
    • Replaced self.workdir (from TestBase) with pytest fixtures (tmp_path, workdir)
    • Changed unittest.mock imports to from unittest import mock for consistency
    • Updated tests to work with autouse fixtures from conftest.py (with_server, with_test_cache)
  • Assertions now consistently use plain assert and pytest.raises, matching the style already used in test_utils/.
  • No functional changes to the OpenML API are introduced; only test implementation is refactored.
  • All 20 tests pass (2 skipped due to platform-specific requirements for Linux/non-Windows).

anirudhsengar avatar Nov 15 '25 10:11 anirudhsengar