test: migrate from Harness to Scenario - #71
Open
tonyandrewmeyer wants to merge 4 commits into
Open
Conversation
tonyandrewmeyer
marked this pull request as ready for review
June 30, 2026 11:40
tonyandrewmeyer
requested review from
Deezzir,
H-M-Quang-Ngo,
chanchiwai-ray,
gabrielcocenza,
jneo8 and
xiywang
June 30, 2026 11:40
|
The functional test failed because of: |
|
fix juju version issue: #73 |
Rewrite the unit tests to use ops.testing's Context/State (Scenario) instead of the deprecated ops.testing.Harness. Behavioural coverage is preserved (same assertions and edge cases); a couple of assertions are adjusted for Scenario's richer model (relation databags include default network data; actions surface results via Context.action_results). Add the ops[testing] extra to the unit test requirements to pull in Scenario.
Treat warnings as errors in the unit tests via filterwarnings = ["error"] in [tool.pytest.ini_options]. No Harness-deprecation ignore is needed now that the suite is migrated to Scenario.
ops 3.x dropped Python 3.8 support, so pip resolves the 2.x line on the 3.8 job, which still ships the Scenario actions.yaml leak. Narrow the -Werror filter to that one warning until a 2.23.x backport or a move to ops 3.8 makes it unnecessary.
The -Werror commit put filterwarnings in pyproject.toml's [tool.pytest.ini_options], which is repo-wide. This repo runs pytest in two tox environments -- tests/unit and tests/functional -- and [testenv:func] invokes plain pytest with no filterwarnings override and no ini of its own, so the functional suite was also being run under -Werror. That is scope creep: the change is meant to promote warnings to errors in the unit tests, not to fail functional runs on deprecations raised inside juju/libjuju/zaza, which this charm does not control. Exempt the functional suite in its existing conftest.py rather than editing tox.ini, which is centrally managed from canonical/solutions-engineering-automation and would be reverted by the soleng-terraform bot. Verified by adding a throwaway functional test that emits a DeprecationWarning: it passes with this exemption and fails without it. Unit suite unchanged: 42 passed, 18 subtests, coverage 92.73%.
tonyandrewmeyer
force-pushed
the
w-error
branch
from
August 17, 2026 05:19
9bd2a06 to
badad78
Compare
jneo8
approved these changes
Aug 17, 2026
chanchiwai-ray
approved these changes
Aug 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces Harness with Scenario (
ops.testingContext/State) across the unit tests, and turns on-Werror(viafilterwarnings = ["error"]inpyproject.toml) so deprecations and resource leaks fail the suite rather than piling up quietly.ops[testing]is added totests/unit/requirements.txtto pull in Scenario.Also picks up a few drive-by reformats in
tests/functional/test_charm.pyfrom running the current Black against it.