fixtures
Fixtures, reusable state for writing clean tests and more.
Decision gist · record as of 2026-08-14
Yes. Fixtures is a mature, actively maintained library with zero security issues, low install friction, and permissive dual licensing. It solves a real problem in test organization—avoiding helper method sprawl on test classes—and integrates cleanly with unittest. Install it if you write unit tests and want cleaner, more reusable test state management.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low friction: pure Python wheel with no runtime dependencies.
- Actively maintained with a recent release and ongoing commits.
- Supports Python 3.10 through 3.14 and PyPy.
License · maintenance · safety
Apache-2.0 or BSD (permissive) — Dual-licensed under Apache-2.0 or BSD (permissive). You may choose either license when using or redistributing.
last release 2026-03-25 (142 days) · last repo commit 2026-07-19 · 35 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 737,050 downloads/mo, #5,190 on PyPI
Alternatives
Verify before relying
import fixtures
import unittest
class MyFixture(fixtures.Fixture):
def _setUp(self):
self.value = 42
self.addCleanup(delattr, self, 'value')
class MyTest(unittest.TestCase, fixtures.TestWithFixtures):
def test_example(self):
fixture = self.useFixture(MyFixture())
self.assertEqual(42, fixture.value)- Whether the optional testtools dependency is required for production use or only for advanced diagnostic features
What it is and what it does
Fixtures is a testing library that defines a contract for reusable state and support logic in unit tests. Rather than accumulating helper methods on test classes (which scales poorly and pollutes class hierarchies), fixtures lets you write standalone, composable objects that manage their own setup and cleanup. Each fixture subclasses the base Fixture class, defines _setUp to initialize state, and schedules cleanups via addCleanup; when cleanUp is called, all scheduled cleanups run in reverse order.
The library includes glue code for unittest integration via TestWithFixtures, which provides a useFixture method that automatically calls setUp, schedules cleanup, and returns the fixture. Fixtures can be composed using useFixture within other fixtures, adapted from functions via FunctionFixture, or combined with CompoundFixture. The package supports context managers and exposes diagnostic details via the testtools content API. It has no runtime dependencies and works with Python 3.10 and later.
Use it for
- Write reusable test fixtures that manage temporary resources (files, databases, servers) without polluting test class hierarchies.
- Compose complex test state from multiple simpler fixtures using useFixture, keeping each fixture focused and independently testable.
- Adapt existing setup/teardown functions or object methods into the Fixture contract using FunctionFixture or MethodFixture.
- Ensure deterministic cleanup of test resources even when multiple cleanups fail, via the MultipleExceptions wrapper.
- Share expensive fixtures across test cases using reset() to efficiently reinitialize state without full teardown and setup.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
Fixtures is a mature, actively maintained library with zero security issues, low install friction, and permissive dual licensing. It solves a real problem in test organization—avoiding helper method sprawl on test classes—and integrates cleanly with unittest. Install it if you write unit tests and want cleaner, more reusable test state management.
Install
fixtures on PyPI
Before you install
Low friction: pure Python wheel with no runtime dependencies. Actively maintained with a recent release and ongoing commits. Supports Python 3.10 through 3.14 and PyPy.
License in practice
Dual-licensed under Apache-2.0 or BSD (permissive). You may choose either license when using or redistributing.
Quickstart
import fixtures
import unittest
class MyFixture(fixtures.Fixture):
def _setUp(self):
self.value = 42
self.addCleanup(delattr, self, 'value')
class MyTest(unittest.TestCase, fixtures.TestWithFixtures):
def test_example(self):
fixture = self.useFixture(MyFixture())
self.assertEqual(42, fixture.value)
Verify before relying
- Whether the optional testtools dependency is required for production use or only for advanced diagnostic features
Package facts
| License | Apache-2.0 or BSD permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 142 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 737,050 / month, #5,190 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 6 - MatureIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Quality AssuranceTopic :: Software Development :: TestingTyping :: Typed |
Evidence: fixtures-4.3.2-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “test fixtures with cleanup”
- fixturesProvides a reusable fixture contract for unit testing that manages…
- pytest-unused-fixturesA pytest plugin that identifies and reports fixtures defined in your…
- pytest-deadfixturesA pytest plugin that identifies unused and duplicated fixtures in…
Give your agent the search over MCP, or paste the wish link into any chat.
More Testing packages
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.
virtualenv creates isolated Python environments where packages can be installed independently without affecting the system Python or other projects.
Coverage.py measures which lines of Python code are executed during test runs, reporting coverage percentages and identifying untested code paths.
Install it if you want to measure test completeness or enforce coverage thresholds in your project.
pytest-asyncio is a pytest plugin that enables writing and running async test functions using the asyncio library, allowing developers to await code directly within test cases.
Install it if you write tests for any asyncio-based code.
A pytest plugin that generates test reports in Common Test Report Format (CTRF) as JSON, compatible with pytest-xdist and pytest-playwright for distributed and browser-based testing.
Install it if you need CTRF-formatted test output for CI/CD integration or cross-tool reporting.
See also django-fixture-magic · pytest-deadfixtures · testresources · pytest-unused-fixtures · pytest-lazy-fixtures · pytest-postgresql · pytest-redis · oslotest · pytest-mock-resources · nutter