{"id":24184,"library":"oslotest","title":"Oslo Test Framework","description":"Oslo test framework provides test utilities and base test classes for OpenStack projects. It helps with test isolation, mocking configuration, and fixture management. Current version: 6.1.1, release cadence is seasonal (aligned with OpenStack releases).","status":"active","version":"6.1.1","language":"python","source_language":"en","source_url":"https://opendev.org/openstack/oslotest","tags":["testing","openstack","fixtures","test-framework"],"install":[{"cmd":"pip install oslotest","lang":"bash","label":"Default install"}],"dependencies":[{"reason":"Required for test fixtures like NestedTempfile, MockPatchObject","package":"fixtures","optional":false},{"reason":"Base test case classes and matchers","package":"testtools","optional":false},{"reason":"Configuration fixture for test setup","package":"oslo.config","optional":false},{"reason":"Used for deprecation warnings in tests","package":"debtcollector","optional":true}],"imports":[{"note":"In oslotest 6.x, the correct import path is `oslotest.base`, which re-exports BaseTestCase from testtools. Importing directly from oslotest.base works but using the module-level `base` is the canonical pattern.","wrong":"from oslotest.base import BaseTestCase","symbol":"BaseTestCase","correct":"from oslotest import base"},{"note":"create_service_fixture is a function, not a module. Import it directly from oslotest.","wrong":"from oslotest.fixture import create_service_fixture","symbol":"create_service_fixture","correct":"from oslotest import create_service_fixture"}],"quickstart":{"code":"import os\nfrom oslotest import base\n\nclass MyTestCase(base.BaseTestCase):\n    def setUp(self):\n        super(MyTestCase, self).setUp()\n        # Use fixtures to set up temp files or env vars\n        self.useFixture(base.NestedTempfile())\n    def test_something(self):\n        result = some_function()\n        self.assertEqual(result, expected)\n\n# For running: python -m testtools.run discover","lang":"python","description":"Minimal test case using Oslo test framework with BaseTestCase and NestedTempfile fixture."},"warnings":[{"fix":"Use `from oslotest import base` and access `base.BaseTestCase`.","message":"Using `oslotest.base.BaseTestCase` directly (instead of through the `base` submodule) is not recommended. The class is re-exported from testtools, and direct imports may break in future versions.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Replace `from oslotest import fake` with `from unittest.mock import Mock` or appropriate mocking.","message":"`oslotest.fake` module is deprecated and may be removed in future versions. Use `unittest.mock` or fixtures instead.","severity":"deprecated","affected_versions":">=5.0"},{"fix":"Consider lighter alternatives like `pytest` or `fixtures` directly if you don't need OpenStack integration.","message":"The `oslotest` package is primarily for OpenStack internal testing. External projects may find it heavy and tied to OpenStack conventions (e.g., configuration files).","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use `from oslotest import base` then `base.BaseTestCase`.","cause":"Incorrect import path. In older versions of oslotest (pre 1.0?), BaseTestCase was at oslotest.base.BaseTestCase, but in current oslotest, BaseTestCase is re-exported via testtools and available via `from oslotest import base` then `base.BaseTestCase`.","error":"ImportError: cannot import name 'BaseTestCase' from 'oslotest'"},{"fix":"Use `unittest.mock` module instead of `oslotest.fake`.","cause":"The fake module was deprecated and removed in oslotest 5.0+.","error":"AttributeError: module 'oslotest' has no attribute 'fake'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}