ops-scenario
Python library providing a state-transition testing API for Operator Framework charms.
Decision gist · record as of 2026-08-14
Yes. ops-scenario is actively maintained, has no known vulnerabilities, carries a permissive license, and is the recommended testing approach for Ops charms. It has low install friction and is designed to integrate seamlessly with ops itself. Install it if you are writing or maintaining Ops charms and want to test them without a full Juju setup.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later; intended to be installed as the testing extra of ops, not directly.
- Low install friction with three straightforward runtime dependencies (ops, PyYAML, typing_extensions).
- The package is actively maintained with a recent release and no known vulnerabilities, making it reliable for test environments.
License · maintenance · safety
Apache-2.0 (permissive) — Licensed under Apache-2.0 (permissive), so you can freely use, modify, and distribute code that depends on it in both open and closed projects without restriction.
last release 2026-07-30 (15 days) · last repo commit 2026-08-10 · 265 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 184,553 downloads/mo, #10,032 on PyPI
Alternatives
Verify before relying
# Install via ops[testing] extra in pyproject.toml:
# test = ['ops[testing]<4.0']
from ops import testing
ctx = testing.Context(MyCharm)
state_in = testing.State()
state_out = ctx.run(ctx.on.start(), state_in)
assert state_out.unit_status == testing.ActiveStatus()- Whether ops-scenario can be installed standalone or only via the ops[testing] extra.
- Exact compatibility matrix between ops-scenario versions and ops versions beyond the 'matching minor and bugfix' statement.
- Whether the testing.Context, testing.State, and related classes are provided by ops-scenario or by ops itself.
What it is and what it does
ops-scenario is a testing library that sits between your code and the Ops framework, letting you write unit tests that simulate Juju state transitions without running a full Juju deployment. You arrange an initial state (including relations, containers, secrets, and config), emit an event through a test context, and assert on the resulting state and any logged output. The library is designed to run at unit-test speeds while covering higher-level behavior than typical unit tests would.
It works by providing test doubles for Juju objects—State, Context, Relation, Container, Secret, and others—that you compose into a scenario. Tests follow the arrange/act/assert pattern, making them straightforward to write and read. The package is tightly integrated with ops itself; when ops-scenario is installed, its classes are exposed through the ops.testing namespace, so you import from ops rather than directly from ops-scenario.
Use it for
- Test that a charm transitions to ActiveStatus after receiving a start event with minimal setup.
- Verify charm behavior when relations change, including data exchange between units and peer relations.
- Simulate container readiness and workload version changes to test container-aware charm logic.
- Test secret handling by arranging secrets in the initial state and asserting on charm actions.
- Validate charm configuration changes by including config in the input state and checking the output.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
ops-scenario is actively maintained, has no known vulnerabilities, carries a permissive license, and is the recommended testing approach for Ops charms. It has low install friction and is designed to integrate seamlessly with ops itself. Install it if you are writing or maintaining Ops charms and want to test them without a full Juju setup.
Install
ops-scenario on PyPI
Before you install
Low install friction with three straightforward runtime dependencies (ops, PyYAML, typing_extensions). The package is actively maintained with a recent release and no known vulnerabilities, making it reliable for test environments.
Requires Python 3.10 or later; intended to be installed as the testing extra of ops, not directly.
License in practice
Licensed under Apache-2.0 (permissive), so you can freely use, modify, and distribute code that depends on it in both open and closed projects without restriction.
Quickstart
# Install via ops[testing] extra in pyproject.toml:
# test = ['ops[testing]<4.0']
from ops import testing
ctx = testing.Context(MyCharm)
state_in = testing.State()
state_out = ctx.run(ctx.on.start(), state_in)
assert state_out.unit_status == testing.ActiveStatus()
Verify before relying
- Whether ops-scenario can be installed standalone or only via the ops[testing] extra.
- Exact compatibility matrix between ops-scenario versions and ops versions beyond the 'matching minor and bugfix' statement.
- Whether the testing.Context, testing.State, and related classes are provided by ops-scenario or by ops itself.
Package facts
| License | Apache-2.0 permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 3 packagesopsPyYAMLtyping_extensions |
| Maintenance | Actively maintained 15 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 184,553 / month, #10,032 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableFramework :: PytestIntended Audience :: DevelopersTopic :: Software Development :: Quality AssuranceTopic :: Software Development :: TestingTopic :: Utilities |
Evidence: ops_scenario-8.8.1-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 › “juju charm unit testing”
- ops-scenarioops-scenario is a state-transition testing framework for Ops charms…
- opsA Python framework for developing charms—declarative, event-driven…
- jubilantJubilant wraps the Juju CLI with a type-annotated Python interface,…
Give your agent the search over MCP, or paste the wish link into any chat.
More Utilities packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Detects and normalizes text encoding from unknown or ambiguous sources, supporting all IANA character sets that Python's core library provides codecs for, with the ability to register custom codecs.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
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.
Pygments is a syntax highlighter that colorizes source code and text in over 500 languages and formats, outputting to HTML, LaTeX, RTF, SVG, images, or ANSI terminal sequences.
Install it if you need to display or transform source code.
Six provides utility functions to write Python code that runs on both Python 2.7 and Python 3.3+, smoothing over language differences between the two versions.
See also ops · pytest-operator · jubilant · juju · cosl · charmlibs-pathops · charmcraftlocal · reactivex · genie.libs.ops · tox-docker