Skip to main content

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] Harness is deprecated. For new charms, and where reasonable for existing charms, prefer the state-transition testing API in ops.testing (the ops-scenario package). ops-harness exists so that charms that still rely on Harness can continue to do so as the class is removed from the core ops distribution.

  • ops-harness requires Python 3.8 or above.
  • It depends on ops 2.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.

Metadata

Release files for ops-harness 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ops-harness 0.1
File Size Uploaded Provenance
ops_harness-0.1.tar.gz 99.3 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ops-harness 0.1
File Interpreter ABI Platform
ops_harness-0.1-py3-none-any.whl Python 3 none any Details

Total release size: 146.9 kB

Release files / ops_harness-0.1.tar.gz

Download URL ops_harness-0.1.tar.gz
Size 99.3 kB
Tags Source
SHA-256 checksum
How to use checksums
bfcd1a6fdd9b35f8adf325dfc5e6ea55dcd628c8039e74b79c9c90b620a4962a
BLAKE2b-256 checksum
How to use checksums
1f3d8a591d784ce34042d105c38e0beef926378f8694de6cf393fb56cd49ce27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 1, 2026.

Transparency log

Release files / ops_harness-0.1-py3-none-any.whl

Download URL ops_harness-0.1-py3-none-any.whl
Size 47.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
40eabee66802fd1026bf19140e7fb8b66e8558c5222090df5a297566523cc9fe
BLAKE2b-256 checksum
How to use checksums
3aae2f4741c184abbdb8eab493c7742011a079e9898773491880cd0a5ca04a97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 1, 2026.

Transparency log

Security for ops-harness 0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ops_harness-0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page