Repository navigation
Clean up warnings and log noise from the test suite - #618
Merged
Merged
Conversation
Three independent sources of noise, all visible when the suite is run the way etstool.py runs it (`python -W default -m unittest discover`), and all hidden by the bare `python -m pytest` used in the GitHub Actions jobs. * `HTTPResourceProtocol.file` caught the `HTTPError` raised by `urlopen` and discarded it without closing. `urllib.response.addbase` subclasses `tempfile._TemporaryFileWrapper`, so an unclosed `HTTPError` emits a `ResourceWarning` when collected -- and in real use leaves the connection underlying the error response to the garbage collector. Close it, guarding against Python 3.8 and 3.9, where an `HTTPError` built with `fp=None` doesn't initialize its file-like base classes and `close()` raises `KeyError`. (3.8 is in the test matrix.) * `envisage.tests.test_plugin.TestPlugin` matched pytest's `Test*` collection pattern but has an `__init__`, so collecting it raised a `PytestCollectionWarning`. Renamed to `SamplePlugin`. * Eleven log records at `WARNING` and above reached `stderr`, from two call sites. Both now have tests that assert them, which is the first coverage either has had; the tests that provoked them only incidentally suppress them instead. The four `envisage.ui.tasks.tasks` warnings from the `TasksApplication` tests are left alone -- those come from building a `TasksApplication` without the `TasksPlugin` that registers the extension point, which looks like a genuine wart rather than test noise, and is worth deciding on separately. Part of #615. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Review feedback: the comment only needs to explain why fp is checked rather than calling close() unconditionally. The rationale for closing at all is in the changelog entry. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Review feedback: * The NoSuchResourceError raised by HTTPResourceProtocol.file reported the address with a "http:://" prefix. Sole occurrence, and no test asserts on the message. * Drop the comment above the assertLogs block in test_exception_in_trait_contribution; the assertions say the same thing. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Reverts the comment to its state on main, byte for byte, so it no longer appears in the diff at all. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This was referenced Aug 5, 2026
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces warning/log noise when running the Envisage test suite under unittest with default warnings enabled, while also addressing an underlying resource-handling bug in HTTPResourceProtocol.file.
Changes:
- Close
HTTPErrorresponses (when safe) before converting toNoSuchResourceError, avoidingResourceWarningand fixing the malformed"http:://"URL in the error path. - Update tests to (a) assert expected
WARNING/ERRORlog records viaassertLogsand (b) suppress incidental warning noise in the provider extension registry test fixture. - Rename a helper plugin class to avoid pytest’s
PytestCollectionWarning, and document the fixes inCHANGES.rst.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| envisage/tests/test_provider_extension_registry.py | Suppresses incidental warning logs in setup and adds a focused assertLogs test for the unknown-extension-point warning. |
| envisage/tests/test_plugin.py | Renames helper class and adds an assertLogs assertion for the expected logger.exception record when trait contributions fail. |
| envisage/resource/http_resource_protocol.py | Closes HTTPError (guarded for 3.8/3.9 fp=None) before raising NoSuchResourceError, and fixes the URL scheme in the raised message. |
| CHANGES.rst | Records the warning/log-noise cleanup and the HTTP resource protocol fix under the current release notes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mdickinson
added a commit
that referenced
this pull request
Aug 5, 2026
Towards #615. **Stacked on #618** — base is `fix/615-test-noise-warnings`, so the diff here is just the one commit. GitHub will retarget this to `main` automatically once #618 merges. It has to be stacked: `filterwarnings = ['error']` only passes once #618's two fixes are in, since both the `ResourceWarning` and the `PytestCollectionWarning` would otherwise fail the suite. ## Why `pyproject.toml` had no `[tool.pytest.ini_options]` section, so pytest ran with Python's default warning filters — which ignore `ResourceWarning` and `ImportWarning` outright. That's precisely why the `ResourceWarning` fixed in #618 was invisible in the GitHub Actions jobs while showing up in the EDM runs, which go through `etstool.py` and use `python -W default -m unittest discover`. Without this, the next warning we introduce is equally invisible. ## The one escape TraitsUI emits an `ImportWarning` at import time when numpy is missing, and numpy isn't in Envisage's dependency closure — the `test-with-pypi` jobs install only `pytest`, `pyside6` and `.`. So it fires there: | environment | `pytest` with `filterwarnings = ['error']` and no escape | | --- | --- | | with numpy | 178 passed | | without numpy | 3 collection errors, all `ImportWarning: ArrayEditor is not available due to missing numpy` | The filter matches on the message rather than ignoring `ImportWarning` as a category, so we keep the protection for any other import warning: ```toml 'ignore:ArrayEditor is not available:ImportWarning', ``` Installing numpy in the test jobs would also have worked, and would exercise more of TraitsUI — but it adds a test-only dependency to the matrix to suppress a warning that isn't telling us anything about Envisage. ## Scope This governs pytest only. The EDM jobs stay at `-W default`: unittest has no config-file equivalent, and making that path strict too would mean putting `-W error` plus escapes into `etstool.py`, which is more coupling than the benefit justifies. The pytest jobs cover 3.8 and 3.10–3.14, which is enough to catch a new warning. ## Verification - Full suite passes on Python 3.8, 3.10, 3.12 and 3.14, with and without numpy: 178 passed each. - Canary check: a test doing `warnings.warn("canary", UserWarning)` now **fails**, confirming the config is in effect rather than silently ignored. - `black --check`, `isort --check`, `flake8` clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This was referenced Aug 5, 2026
Closed
mdickinson
added a commit
that referenced
this pull request
Aug 5, 2026
Closes #615. This removes the last four WARNING-level log records from the test suite — the ones #618 deliberately deferred. ## The behaviour is fine; the tests were misconfigured #618 predicted this was "a wart to fix rather than noise to silence", on the grounds that any application subclassing `TasksApplication` without `TasksPlugin` warns at startup. Investigating that under #620 turned up the opposite conclusion: `TasksApplication` needs `TasksPlugin`, so an application without it is misconfigured, and the warning is doing its job. The registration path, for the record: 1. `Application.extension_registry` defaults to `PluginExtensionRegistry(plugin_manager=self)`. 2. Each plugin is added as a provider; `ProviderExtensionRegistry._add_provider_extension_points` (`provider_extension_registry.py:159`) stores whatever `provider.get_extension_points()` returns. 3. `Plugin.get_extension_points` (`plugin.py:107`) returns the trait *type* of every trait marked `__extension_point__=True`. 4. `TasksPlugin.tasks` (`tasks_plugin.py:88`) carries `id = "envisage.ui.tasks.tasks"`, which is exactly `TasksApplication.TASK_FACTORIES` (`tasks_application.py:48`). Same for `task_extensions`. What makes the dependency easy to miss is that the two sides share no *name* — the consumer trait is `task_factories`, the provider trait is `tasks`. Only the id string ties them together. That the plugin is required is not a novel claim: * `run_attractor.py:23`, the only complete Tasks example in the tree, builds `[CorePlugin(), TasksPlugin(), AttractorsPlugin()]`, and `AttractorsPlugin` is a pure contributor — `tasks = List(contributes_to="envisage.ui.tasks.tasks")` — relying on `TasksPlugin` to have declared the point. * `docs/source/tasks_user_manual/extensibility.rst:22` has a section headed "The Tasks Plugin" describing it as the owner of those extension points. So the pattern of declaring a read-only `ExtensionPoint` trait on a consumer is not penalised by the warning: it is silent whenever the companion plugin is present, which supported usage ensures. Verified both ways — with `TasksPlugin` in the plugin list, no warning and no ordering hazard; without it, the warning. ## The change The four noisy tests built a bare `TasksApplication` with no plugins, `_default_layout_default` read `self.task_factories`, and the registry warned. All seven constructions in the file now go through a `create_tasks_application` helper that supplies `TasksPlugin`. A helper rather than seven copies of `plugins=[TasksPlugin()]`, so the invariant is stated once in the place that explains why — otherwise it reads as incidental boilerplate that could be stripped out, bringing the noise back. Applied to all seven sites, not just the four noisy ones, so tests added later inherit it. `test_lifecycle_with_plugin` asserts an exact event sequence; that is undisturbed, as `TasksPlugin` fires no lifecycle events of its own. ## Not changed `ProviderExtensionRegistry._get_extensions` keeps the warning, so the test-side coupling #618 introduced stays correct and needs no edit: both `test_get_extensions_of_unknown_extension_point` and the `setUp` logger suppression in `test_provider_extension_registry.py` remain valid. That suppression is not dead code under this resolution. The API asymmetry #618 also flagged — `ExtensionRegistry.get_extensions` silent on an unknown id, `ProviderExtensionRegistry`'s warning, `set_extensions` and `remove_extension_point` raising `UnknownExtensionPoint` — is untouched and still deserves its own discussion. ## Verification The seven tests in this file are `@requires_gui`, so they skip silently without a toolkit installed; runs below inject PySide6. * Before: exactly the four tests named in #620 emitted `getting extensions of unknown extension point <envisage.ui.tasks.tasks>`. * After: zero occurrences anywhere in the suite under `--log-cli-level=WARNING`; 178 passed, none skipped, no warnings. * `black --check`, `isort --check` and `flake8` clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
mdickinson
added a commit
that referenced
this pull request
Aug 5, 2026
Closes #616. Envisage now requires Python 3.10 or later. ## Changes - `requires-python` is bumped to `>= 3.10`, and the conditional `importlib-resources` dependency is dropped. `importlib.resources` has provided `files` and `as_file` since 3.9, so the five `try`/`except ImportError` import blocks become plain imports. - `HTTPResourceProtocol.file` closes the caught `HTTPError` unconditionally again. The `exc.fp is not None` guard added in #618 was needed only because `close()` raised `KeyError: 'file'` on 3.8 and 3.9 when the error had no `fp`; on 3.10+ `self.fp` becomes an `io.BytesIO` and `close()` works. - The EDM runtime lists in `etstool.py` and the two EDM workflows lose 3.8, leaving 3.11. The `linux_runtime_platform` mapping and the `--platform` flag it fed go with it: they existed only to select `rh7_x86_64` for the 3.8 runtime, and 3.11 uses EDM's default `rh8_x86_64`. The `macos-latest` / 3.8 matrix exclusions go too. - The `test-with-pypi` matrix drops 3.8, leaving 3.10 through 3.14. - The stale comment explaining that PySide2 and PyQt5 are unavailable for EDM + Python 3.8 is removed. The existing `pkg_resources` entry in `CHANGES.rst` described `importlib-resources` as a backport for Python 3.8, which is no longer true, so that parenthetical is edited out rather than left to contradict the new entry. ## Verification - `pytest`: 171 passed, 7 skipped (no toolkit installed) on both 3.15 and a clean 3.10 environment. - `python -W default -m unittest discover -t . -s envisage`: 178 tests OK, no new warnings. - `test_resource_manager` under `-W error` on 3.10, to confirm the unguarded `exc.close()` is safe there. - `black --check`, `isort --check`, `flake8` clean. - `python -m build` plus `twine check --strict` pass; the wheel metadata reports `Requires-Python: >=3.10` and no `importlib-resources` in `Requires-Dist`. ## One point for review The EDM matrices are now single-runtime, since 3.8 was the only other entry. `available_runtimes`, `supported_combinations` and the `--runtime` option are all still in place, so adding a runtime is a one-line change. If EDM offers something newer than 3.11 it would be worth adding here, rather than leaving the EDM jobs covering a single version. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
mdickinson
added a commit
that referenced
this pull request
Aug 5, 2026
A review of the 8.0.0 changelog against `7.0.4..main`. 7.0.4 was tagged directly on main — `0c02d0b` is both the tag commit and the merge-base — so that range is exact. It holds 30 non-merge commits: 11 touching the library or packaging, 19 CI and infrastructure. ## The library side was already complete All eight substantive changes had entries, and both deprecations 7.0.0 promised to remove in 8.0 (#540, #544) are removed and listed. No `DeprecationWarning` remains anywhere in the library, so nothing is left dangling for 9.0. ## References now point at PRs, not issues The two `Fixes` entries for the `HTTPError` leak cited #615, whose title is "Clean up test noise from warnings and WARNING-level log messages". The leak was found *via* that cleanup, but a reader following the reference lands on a test-hygiene issue rather than a resource-leak fix. Rather than fix those two in isolation, every reference in the section now points at the PR that made the change: #574→#613, #616→#622, #548→#599, #547→#612, #614→#617, and #615→#618/#619/#621 as appropriate. This also supplies the reference the `pkg_resources` entry was missing — #600, the PR, rather than #515, the issue. Two notes: - The "no longer writes `WARNING`-level log messages" entry cites **both** #618 and #621. #618 deliberately deferred the four `envisage.ui.tasks.tasks` records from the `TasksApplication` tests to a follow-up, so the claim only became true once #621 landed. - Sections for 7.0.4 and earlier are untouched; they already cite PRs. ## CI and build work added Nineteen PRs had no entry at all, in contrast with 7.0.4, which listed its action bumps and copyright-header updates under `Build`. Five new entries cover them, aggregated where the work was one theme: | Entry | PRs | | --- | --- | | Trusted publishing (OIDC) and SHA-pinned actions | #604, #608 | | Copyright end years, and the year-rollover fix to the style check | #596, #597, #607 | | GitHub Action bumps | #591, #592, #593, #594, #595, #602, #603, #605, #606, #609, #610 | | Pre-release Pythons in the CI matrix | #601, #624 | | `AGENTS.md` | #598, #626 | Trusted publishing changes how releases are authenticated, so it seemed worth naming rather than folding into the general CI churn. ## Judgment calls worth a second opinion **The CI matrix entry names no versions.** It reads "now includes pre-release Python versions" rather than "3.14, and 3.15 pre-releases". Naming them is more informative, but in a section whose `Removals` entry deliberately gives no upper bound on supported Pythons, a `Build` line ending in "3.15" invites exactly the reading that bound was left out to avoid. Easy to change if you'd rather have the numbers. **No upper bound on Python versions.** Considered and rejected: it means churn on every Python release, and forwards compatibility is the reasonable default expectation for a package that runs warning-free on the current version. **Deliberate omissions.** #626's other cleanups — an `IServiceRegistry` docstring, the legacy examples README, dead Traits<6.0 test code — change nothing for users. There's no `Documentation` section because the doc edits in #599 are just the egg-manager material going away with the classes, already covered by the `Removals` entry. And `CorePlugin` gaining its own `stop()` to unregister service offers is an implementation move; the #617 entry already notes that `PluginActivator` no longer calls `register_services`/`unregister_services`, which is the part a downstream `Plugin` subclass would notice. ## Left to the release PR The `Released:` date line, an introductory paragraph, a "Thanks to:" list, and the `version = '7.0.4'` still in `pyproject.toml`. The date isn't settled yet. ## Verification `CHANGES.rst` parses under docutils with no warnings at report level 2 or above, and all lines stay within 79 characters. Changelog only — no code touched. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Towards #615. This covers the parts of that issue that are unambiguous; the
TasksApplicationwarnings are deliberately left for a follow-up (see the end).Why this wasn't visible in CI
The noise appears under
python -W default -m unittest discover -v envisage— whatetstool.py:357runs. The GitHub Actions jobs run barepython -m pytest, which captures logging and shows it only on failure, and which hidesResourceWarningby default. So the suite has looked clean on GitHub while the EDM runs have not been.1.
ResourceWarningfrom the resource manager testsThis one is a real defect, not a test artifact.
urllib.response.addbasesubclassestempfile._TemporaryFileWrapper, so anHTTPErroris a temp-file wrapper and warns if it's collected unclosed.HTTPResourceProtocol.filecaughtHTTPErrorand discarded it without closing, which in real use leaves the connection underlying the error response to the garbage collector rather than releasing it promptly.The fix closes it, with a guard that matters:
HTTPError(..., fp=None).close()self.fpstaysNone, file-like bases never initializedKeyError: 'file'self.fpbecomes anio.BytesIO3.8 is in the
test-with-pypimatrix, so an unguardedexc.close()would have broken CI there — and would have been a genuine regression for any caller raisingHTTPErrorwithfp=Noneon those versions. Henceif exc.fp is not None. This also explains why the warning is recent: on 3.8/3.9 thefp=Nonecase produced no wrapper and so no warning at all.Verified on 3.8, 3.10 and 3.14.
2.
PytestCollectionWarningenvisage.tests.test_plugin.TestPluginmatched pytest'sTest*collection glob but has an__init__. It's only used for a__repr__assertion, so it's renamed toSamplePlugin.3. Log records reaching
stderrEleven records at
WARNINGand above, from two call sites:provider_extension_registry.py:85— unknown extension pointtest_provider_extension_registry(2 via the shared mixin)plugin.py:287—logger.exceptionon a failing contributiontest_exception_in_trait_contributionprovider_extension_registry.py:85— as abovetest_tasks_application— left alone, see belowEvery one of these is expected behaviour being deliberately provoked. The review that preceded this PR also found that no test in the suite asserted any log output (
assertLogscount: 0), even though these are exactly theWARNING+ messages worth pinning down. So rather than only silencing them:test_exception_in_trait_contributionnow asserts theERRORrecord and that it carriesexc_info— i.e. thatlogger.exceptionreally attaches the traceback before re-raising.test_get_extensions_of_unknown_extension_pointasserts theWARNINGand the empty return value.ExtensionRegistryTestMixin, which is shared withtest_extension_registry.pywhere the plainExtensionRegistryis silent for the same input. Wrapping those inassertLogswould either need the mixin to grow a registry-specific hook or would assert a coincidence of the mixin's implementation, so they're suppressed at the level ofProviderExtensionRegistryTestCase.setUpinstead, with a comment pointing at the test that does assert the behaviour.assertLogsoverrides a logger level set that way, so the assertions above still work.The tradeoff worth flagging: that suppression is scoped to one logger and one test class, but it would hide an unexpected new
WARNINGfrom that logger in those tests. I think that's acceptable now that the behaviour has a dedicated test, but say the word if you'd rather have the mixin hook.Deliberately not addressed
The four
getting extensions of unknown extension point <envisage.ui.tasks.tasks>records fromtest_tasks_application.TasksApplicationdeclarestask_factories = ExtensionPoint(id="envisage.ui.tasks.tasks")(tasks_application.py:85), but the point is only registered byTasksPlugin(tasks_plugin.py:88). The tests build a bareTasksApplicationwith no plugins,_default_layout_defaultreadsself.task_factories, and the registry warns — which means any real application subclassingTasksApplicationwithout includingTasksPlugingets the same warning at startup. That looks like a wart to fix rather than noise to silence, and it sits next to a related asymmetry (ExtensionRegistry.get_extensionson an unknown id is silent;ProviderExtensionRegistry's warns;set_extensionsandremove_extension_pointraiseUnknownExtensionPoint). Both deserve their own discussion.Verification
pytest: 178 passed, 0 warnings (was 177 passed, 1 warning).python -W default -m unittest discover -t . -s envisageon 3.8, 3.10, 3.14: OK, with only the four deferredtasksrecords remaining.black --check,isort --check,flake8clean, using the pinnedblack ~= 24.3fromstyle-requirements.txt.🤖 Generated with Claude Code