pytest-operator
Fixtures for Charmed Operators
Decision gist · record as of 2026-08-14
Yes, if you are writing integration tests for Juju operator charms. The plugin is actively maintained, has no known vulnerabilities, uses a permissive license, and provides real value by reducing boilerplate for a specialized testing domain. The low install friction and stable dependency set make it a straightforward addition to a charm testing workflow.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.8 or later; assumes you have a Juju environment available for the ops_test fixture to connect to.
- Low friction installation; active maintenance with a recent release (2025-10-04) and last commit on 2026-04-09.
- Depends on pytest, juju, and pytest-asyncio, all standard testing libraries.
License · maintenance · safety
Apache (permissive) — Apache license (permissive) means you can use this in commercial and open-source projects with minimal restrictions; include a copy of the license and note any modifications.
last release 2025-10-04 (314 days) · last repo commit 2026-04-09 · 10 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 152,528 downloads/mo, #10,898 on PyPI
Alternatives
Verify before relying
# In tox.ini or requirements:
pip install pytest-operator
# In your test file:
import pytest
@pytest.mark.abort_on_fail
async def test_build_and_deploy(ops_test):
my_charm = await ops_test.build_charm(".")
await ops_test.model.deploy(my_charm)
await ops_test.model.wait_for_idle()- Whether the package requires a running Juju controller or if it can mock/stub the Juju connection for unit testing.
- Performance characteristics when running large numbers of integration tests in parallel.
- Compatibility with different Juju versions beyond what the classifiers indicate.
What it is and what it does
pytest-operator is a pytest plugin designed to simplify writing integration tests for Juju operator charms. It provides an `ops_test` fixture that wraps a libjuju Model and offers helper methods for building charms, managing resources, rendering bundles, and deploying to a Juju environment. The fixture is module-scoped and includes conveniences like automatic async test marking and the ability to abort remaining tests in a module if a critical test fails.
You use it by including it in your test dependencies and then calling methods like `ops_test.build_charm()`, `ops_test.build_resources()`, and `ops_test.model.deploy()` within async test functions. It handles the boilerplate of connecting to a Juju model and provides utilities for rendering Jinja2 templates (for bundle files) and running juju CLI commands directly when needed.
Use it for
- Test charm deployment and lifecycle by building a charm locally and verifying it reaches active status.
- Validate charm resources are correctly built or downloaded and attached during deployment.
- Render and deploy multi-charm bundles with templated configuration for integration testing.
- Verify charm behavior after deployment by inspecting model state and application status.
- Abort a test module early if an initial deployment test fails, marking dependent tests as xfailed.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you are writing integration tests for Juju operator charms.
The plugin is actively maintained, has no known vulnerabilities, uses a permissive license, and provides real value by reducing boilerplate for a specialized testing domain. The low install friction and stable dependency set make it a straightforward addition to a charm testing workflow.
Install
pytest-operator on PyPI
Before you install
Low friction installation; active maintenance with a recent release (2025-10-04) and last commit on 2026-04-09. Depends on pytest, juju, and pytest-asyncio, all standard testing libraries.
Requires Python 3.8 or later; assumes you have a Juju environment available for the ops_test fixture to connect to.
License in practice
Apache license (permissive) means you can use this in commercial and open-source projects with minimal restrictions; include a copy of the license and note any modifications.
Quickstart
# In tox.ini or requirements:
pip install pytest-operator
# In your test file:
import pytest
@pytest.mark.abort_on_fail
async def test_build_and_deploy(ops_test):
my_charm = await ops_test.build_charm(".")
await ops_test.model.deploy(my_charm)
await ops_test.model.wait_for_idle()
Verify before relying
- Whether the package requires a running Juju controller or if it can mock/stub the Juju connection for unit testing.
- Performance characteristics when running large numbers of integration tests in parallel.
- Compatibility with different Juju versions beyond what the classifiers indicate.
Package facts
| License | Apache permissive |
| Python support | Supports the current Python release >=3.8 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 6 packagesipdbpytestpytest-asynciopyyamljujujinja2 |
| Maintenance | Actively maintained 314 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 152,528 / month, #10,898 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | License :: OSI Approved :: Apache Software LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9 |
Evidence: pytest_operator-0.43.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 › “pytest operator charm testing”
- pytest-operatorA pytest plugin that provides fixtures and helpers for writing…
- jubilantJubilant wraps the Juju CLI with a type-annotated Python interface,…
- ops-scenarioops-scenario is a state-transition testing framework for Ops charms…
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 ops-scenario · ops · jubilant · cosl · pytest-factoryboy · pytest-aio · pytest-markdown-docs · pytest-redis · data-platform-helpers · pytest-lazy-fixture