Registry / testing / oslotest

oslotest

JSON →
library6.1.1pypypi✓ verified 83d ago

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).

pip install oslotest
INSTALL
IMPORT
SIG · OSLOTEST
O
oslotest
testingpythonv6.1.1
Install
1.8s avg
Import
549ms
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v6.1.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.600s · 19.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.8s · import 0.498s · 20MB
18MB installed
● package 18MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BaseTestCase
from oslotest import base
from oslotest.base import BaseTestCase
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.
create_service_fixture
from oslotest import create_service_fixture
from oslotest.fixture import create_service_fixture
create_service_fixture is a function, not a module. Import it directly from oslotest.

Minimal test case using Oslo test framework with BaseTestCase and NestedTempfile fixture.

import os from oslotest import base class MyTestCase(base.BaseTestCase): def setUp(self): super(MyTestCase, self).setUp() # Use fixtures to set up temp files or env vars self.useFixture(base.NestedTempfile()) def test_something(self): result = some_function() self.assertEqual(result, expected) # For running: python -m testtools.run discover
Debug
Known issues
gotchaUsing `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.
fix
Use `from oslotest import base` and access `base.BaseTestCase`.
affects: >=1.0
deprecated`oslotest.fake` module is deprecated and may be removed in future versions. Use `unittest.mock` or fixtures instead.
fix
Replace `from oslotest import fake` with `from unittest.mock import Mock` or appropriate mocking.
affects: >=5.0
gotchaThe `oslotest` package is primarily for OpenStack internal testing. External projects may find it heavy and tied to OpenStack conventions (e.g., configuration files).
fix
Consider lighter alternatives like `pytest` or `fixtures` directly if you don't need OpenStack integration.
affects: all
Errors
Common errors & fixes
ImportError: cannot import name 'BaseTestCase' from 'oslotest'
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`.
fix
Use `from oslotest import base` then `base.BaseTestCase`.
AttributeError: module 'oslotest' has no attribute 'fake'
The fake module was deprecated and removed in oslotest 5.0+.
fix
Use `unittest.mock` module instead of `oslotest.fake`.
Upgrade
Version history
6.1.1latest on PyPI · released Apr 20, 2026
Audit
Dependencies
fixturesrequiredRequired for test fixtures like NestedTempfile, MockPatchObject
testtoolsrequiredBase test case classes and matchers
oslo.configrequiredConfiguration fixture for test setup
debtcollectoroptionalUsed for deprecation warnings in tests
Agent activity
2 hits · last 30 days
node
2
Resources
oslotest — pip install oslotest · libregistry