{"library":"ops-scenario","title":"ops-scenario","description":"A Python library for state-transition testing of Juju charms built with the Operator Framework. Provides the `ops.testing` module with the `Context` API to simulate charm lifecycle events and validate state changes. Current version: 8.7.0 (2026). Requires Python >=3.10. Active development with frequent releases.","language":"python","status":"active","last_verified":"Fri May 01","install":{"commands":["pip install ops[testing]","pip install ops-scenario"],"cli":null},"imports":["from ops.testing import Context","from ops.testing import State","from ops.testing import CharmSpec"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nimport yaml\nfrom ops.charm import CharmBase\nfrom ops.testing import Context, State, CharmSpec\n\nclass MyCharm(CharmBase):\n    def __init__(self, *args):\n        super().__init__(*args)\n        self.framework.observe(self.on.install, self._on_install)\n\n    def _on_install(self, event):\n        self.unit.status.set_active()\n\ndef test_charm():\n    metadata = yaml.safe_load('''\nname: my-charm\nsummary: test\nseries: [focal]\n''')\n    spec = CharmSpec(MyCharm, meta=metadata)\n    ctx = Context(spec, meta={'name': 'my-charm'}, actions=None, config=None)\n    state = ctx.run('install', State())\n    assert state.unit_status.name == 'active'\n    print('Test passed')\n\nif __name__ == '__main__':\n    test_charm()","lang":"python","description":"Minimal test: creates a charm, runs the install event, asserts active status.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}