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
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.600s · 19.2MB
glibcpy 3.10–3.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
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`.
fixUse `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+.
fixUse `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