{"library":"pytest-operator","title":"pytest-operator","description":"pytest-operator provides a set of pytest fixtures designed to simplify the testing of Charmed Operators, particularly for integration and functional tests. It abstracts away much of the complexity of deploying and managing Juju models and charms within a test environment. The current version is 0.43.2, and it maintains an active release cadence with frequent patch updates and occasional minor feature releases.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install pytest-operator"],"cli":null},"imports":["pytest_plugins = ['pytest_operator.plugin']"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"# conftest.py\npytest_plugins = [\"pytest_operator.plugin\"]\n\n# tests/integration/test_my_charm.py\nimport pytest\nfrom pathlib import Path\n\n# Assuming your charm source is in a 'src' directory relative to the tests\nCHARM_ROOT = Path(__file__).parent.parent / \"src\"\n\nasync def test_charm_is_deployed(ops_test):\n    # Build the charm locally\n    charm = await ops_test.build_charm(CHARM_ROOT)\n    \n    # Deploy the charm to the ephemeral Juju model\n    await ops_test.model.deploy(charm)\n    \n    # Wait for the application to reach an idle state\n    await ops_test.model.wait_for_idle(apps=[charm.name], status=\"active\", timeout=600)\n    \n    # Assertions about the application state\n    assert ops_test.model.applications[charm.name].units[0].workload_status == \"active\"","lang":"python","description":"This quickstart demonstrates a basic integration test using `pytest-operator`. It shows how to declare the plugin in `conftest.py`, build a charm using `ops_test.build_charm()`, deploy it to a temporary Juju model, and assert its status. Ensure `charmcraft` is installed if you are building charms locally.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}