--- id: pytest-operator version: "0.43.2" license: Apache license_treatment: permissive maintenance: active --- # pytest-operator — Fixtures for Charmed Operators License: permissive · Maintenance: active · Downloads: 152.5K/mo ## 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 above — verify before relying. A pytest plugin that provides fixtures and helpers for writing integration tests of Juju operator charms, including charm building, resource management, and model deployment. 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 pip install pytest-operator uv add pytest-operator poetry add pytest-operator ## Installing pytest-operator 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. 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() Requires Python 3.8 or later; assumes you have a Juju environment available for the ops_test fixture to connect to. 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_current - Install friction: low - Maintenance: active - Downloads: 152.5K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags pytest operator charm testing, juju charm integration tests, operator charm test fixtures, pytest juju deployment, charm resource testing, operator integration testing framework, juju-charms, integration-testing, operator-framework [View on SkillFed](https://skillfed.io/packages/pytest-operator) · [View on PyPI](https://pypi.org/project/pytest-operator/)