diff --git a/docs/release-notes/artifacts/werror-unit-tests.yaml b/docs/release-notes/artifacts/werror-unit-tests.yaml new file mode 100644 index 00000000..e5a92006 --- /dev/null +++ b/docs/release-notes/artifacts/werror-unit-tests.yaml @@ -0,0 +1,15 @@ +# --- Release notes artifact ---- + +schema_version: 1 +changes: + - title: Run the unit tests with warnings promoted to errors + author: tonyandrewmeyer + type: chore + description: | + The unit tests now run with `filterwarnings = ["error", ...]`, so a deprecation or resource leak fails the suite instead of scrolling past in the log. Three third-party warnings are ignored by message; the charm's own code raises none. Integration tests are unaffected. + urls: + pr: https://github.com/canonical/indico-operator/pull/776 + related_doc: + related_issue: + visibility: internal + highlight: false diff --git a/pyproject.toml b/pyproject.toml index be30603f..16d40bc3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,6 +17,20 @@ pythonpath = [ "lib", "src", ] +# Turn warnings into errors so deprecations and resource leaks fail the unit +# suite rather than accumulating unnoticed. Each ignore below is anchored to a +# specific message and is for third-party code; the charm's own code raises +# none. The integration env opts out (see tox.ini) because the warnings there +# come from juju/websockets and are not ours to fix. +filterwarnings = [ + "error", + # Raised by the vendored loki_k8s charm lib and by paas_charm; the fixes + # belong upstream in canonical/loki-k8s-operator and canonical/paas-charm. + "ignore:JujuVersion.from_environ\\(\\) is deprecated:DeprecationWarning", + # paas_charm.charm_state calls pydantic's deprecated BaseModel.dict(); + # the fix belongs upstream in canonical/paas-charm. + "ignore:The `dict` method is deprecated; use `model_dump` instead:DeprecationWarning", +] # Linting tools configuration [tool.ruff] diff --git a/tox.ini b/tox.ini index abd4c8a0..b499087d 100644 --- a/tox.ini +++ b/tox.ini @@ -91,5 +91,6 @@ commands = -s \ --tb native \ --log-cli-level=INFO \ + --override-ini=filterwarnings= \ {posargs} \ {[vars]tests_path}/integration