Testing the Python library behind great charms
Project description
ops-harness
ops-harness provides Harness, the legacy unit-testing API for charms built
with the ops framework. It packages the
Harness class as a standalone distribution that ops re-exports as
ops.testing.Harness -- the same way ops re-exports the ops-scenario
package's state-transition API under ops.testing.
[!IMPORTANT]
Harnessis deprecated. For new charms, and where reasonable for existing charms, prefer the state-transition testing API inops.testing(theops-scenariopackage).ops-harnessexists so that charms that still rely onHarnesscan continue to do so as the class is removed from the coreopsdistribution.
ops-harnessrequires Python 3.8 or above.- It depends on
ops2.23 or above.
Installation
pip install ops-harness
Or, with uv:
uv add ops-harness
Usage
Add ops-harness to your charm's test dependencies, then import Harness from
ops.testing:
from ops.testing import Harness
from charm import MyCharm
def test_config_changed():
harness = Harness(MyCharm, meta="name: my-charm")
harness.begin()
harness.update_config({"log-level": "debug"})
assert harness.charm.model.config["log-level"] == "debug"
harness.cleanup()
For the full API, see the
ops.testing.Harness reference documentation.
Contributing and developing
Anyone can contribute to ops-harness. See CONTRIBUTING.md
for the contribution process, and HACKING.md for how to set up a
development environment and run the tests.
Code of conduct
When contributing, you must abide by the Ubuntu Code of Conduct.
License
ops-harness is free software, distributed under the Apache Software License,
version 2.0. See LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ops_harness-0.1.tar.gz.
File metadata
- Download URL: ops_harness-0.1.tar.gz
- Upload date:
- Size: 99.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bfcd1a6fdd9b35f8adf325dfc5e6ea55dcd628c8039e74b79c9c90b620a4962a
|
|
| MD5 |
f600e4f48f547b19838dd8ee512a2607
|
|
| BLAKE2b-256 |
1f3d8a591d784ce34042d105c38e0beef926378f8694de6cf393fb56cd49ce27
|
Provenance
The following attestation bundles were made for ops_harness-0.1.tar.gz:
Publisher:
publish-pypi.yaml on tonyandrewmeyer/ops-harness
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ops_harness-0.1.tar.gz -
Subject digest:
bfcd1a6fdd9b35f8adf325dfc5e6ea55dcd628c8039e74b79c9c90b620a4962a - Sigstore transparency entry: 1688423538
- Sigstore integration time:
-
Permalink:
tonyandrewmeyer/ops-harness@4d3dd3eb3001477c65b17e8c24a1788abc9723ed -
Branch / Tag:
refs/tags/v1.0.0b1 - Owner: https://github.com/tonyandrewmeyer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yaml@4d3dd3eb3001477c65b17e8c24a1788abc9723ed -
Trigger Event:
push
-
Statement type:
File details
Details for the file ops_harness-0.1-py3-none-any.whl.
File metadata
- Download URL: ops_harness-0.1-py3-none-any.whl
- Upload date:
- Size: 47.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40eabee66802fd1026bf19140e7fb8b66e8558c5222090df5a297566523cc9fe
|
|
| MD5 |
f605777ac163929c5fe5daaab9f1940e
|
|
| BLAKE2b-256 |
3aae2f4741c184abbdb8eab493c7742011a079e9898773491880cd0a5ca04a97
|
Provenance
The following attestation bundles were made for ops_harness-0.1-py3-none-any.whl:
Publisher:
publish-pypi.yaml on tonyandrewmeyer/ops-harness
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ops_harness-0.1-py3-none-any.whl -
Subject digest:
40eabee66802fd1026bf19140e7fb8b66e8558c5222090df5a297566523cc9fe - Sigstore transparency entry: 1688423623
- Sigstore integration time:
-
Permalink:
tonyandrewmeyer/ops-harness@4d3dd3eb3001477c65b17e8c24a1788abc9723ed -
Branch / Tag:
refs/tags/v1.0.0b1 - Owner: https://github.com/tonyandrewmeyer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yaml@4d3dd3eb3001477c65b17e8c24a1788abc9723ed -
Trigger Event:
push
-
Statement type: