testscenarios
Testscenarios, a unittest extension for dependency injection
Decision gist · record as of 2026-08-14
Yes. testscenarios is a mature, actively maintained library with no security vulnerabilities, low install friction, and permissive dual licensing. It solves a genuine unittest limitation for interface and parameterized testing. Install if you need to run the same test logic across multiple scenarios or implementations without creating brittle subclass hierarchies.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later.
- If subclassing TestWithScenarios, it must be first in the MRO and you cannot override run() or __call__().
- Low install friction with a pure-Python wheel.
License · maintenance · safety
Apache-2.0 OR BSD-3-Clause (permissive) — Dual-licensed under Apache-2.0 or BSD-3-Clause (permissive). You may choose either license when using or redistributing the package.
last release 2026-05-22 (84 days) · last repo commit 2026-05-22 · 7 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 443,005 downloads/mo, #6,631 on PyPI
Alternatives
Verify before relying
import unittest
from testscenarios import TestWithScenarios
class MyTest(TestWithScenarios):
scenarios = [
('scenario1', {'param': 1}),
('scenario2', {'param': 2}),
]
def test_example(self):
self.assertEqual(self.param, self.param)- Whether the package works with test runners beyond unittest (e.g., pytest, nose) without additional configuration.
- Performance characteristics when generating large numbers of scenarios dynamically.
What it is and what it does
testscenarios is a unittest extension that enables clean dependency injection and parameterization of tests through scenarios. A scenario is a named tuple pairing a string identifier with a dictionary of parameters; the package multiplies a single test method across all scenarios, cloning the test and injecting each scenario's parameters as attributes on the test instance.
The package addresses a key limitation of unittest: running the same test logic against multiple implementations or configurations without creating brittle mixin-based subclasses. It supports three integration patterns: subclassing TestWithScenarios (most robust, works with any unittest-compliant runner), manual generation via generate_scenarios(), or hooking into test loader conventions like load_tests. Scenarios can be static class attributes or dynamically generated at runtime, and can be composed across multiple dimensions to create cross-product test expansion.
Use it for
- Testing multiple implementations of the same interface by defining scenarios for each backend or provider.
- Running the same test suite against different configurations (e.g., database engines, network transports) without code duplication.
- Plugin systems where a plugin needs to run standard interface tests against its own implementation.
- Dependency injection: providing tests with externally-configured objects or settings to test behavior in different contexts.
- Generating test variants dynamically based on available libraries or registry entries at test load time.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
testscenarios is a mature, actively maintained library with no security vulnerabilities, low install friction, and permissive dual licensing. It solves a genuine unittest limitation for interface and parameterized testing. Install if you need to run the same test logic across multiple scenarios or implementations without creating brittle subclass hierarchies.
Install
testscenarios on PyPI
Before you install
Low install friction with a pure-Python wheel. Actively maintained as of 2026-05-22 with recent activity. Requires Python 3.10 or later and has no runtime dependencies.
Requires Python 3.10 or later. If subclassing TestWithScenarios, it must be first in the MRO and you cannot override run() or __call__().
License in practice
Dual-licensed under Apache-2.0 or BSD-3-Clause (permissive). You may choose either license when using or redistributing the package.
Quickstart
import unittest
from testscenarios import TestWithScenarios
class MyTest(TestWithScenarios):
scenarios = [
('scenario1', {'param': 1}),
('scenario2', {'param': 2}),
]
def test_example(self):
self.assertEqual(self.param, self.param)
Verify before relying
- Whether the package works with test runners beyond unittest (e.g., pytest, nose) without additional configuration.
- Performance characteristics when generating large numbers of scenarios dynamically.
Package facts
| License | Apache-2.0 OR BSD-3-Clause permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 84 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 443,005 / month, #6,631 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.14Topic :: Software Development :: Quality AssuranceTopic :: Software Development :: Testing |
Evidence: testscenarios-0.6.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 scenario injection”
- testscenariostestscenarios extends Python's unittest to run a single test method…
- pytest-lazy-fixturesAllows you to reference pytest fixtures directly within…
- pytest-bddpytest-bdd implements Gherkin-based behavior-driven development…
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 parametrize · parameterized · pytest-subtests · testresources · concurrencytest · pynose · ddt · unittest2 · softest · zope.testrunner