Repository navigation
test: reset the themed console singleton between tests - #4788
Merged
Daniel Meppiel (danielmeppiel) merged 1 commit intoNov 22, 2026
Merged
Conversation
The themed console returned by commands/_helpers._get_console is a module singleton whose width Rich fixes when it is built. The autouse _reset_console_state fixture reset utils.console and rich._console but not utils.themed_console._console, so the first test on an xdist worker fixed the width for every later test. test_outdated_command's 80-column fold assertion then saw a ~124-column table depending on shard order. Reset themed_console._console in the shared fixture (now a reset_console_singletons helper) and extend the existing guard test to assert it is nulled before and after each test. Fixes #4773 Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 22, 2026 17:59
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the test-only console-state cleanup change.
No open issues 🎉
What changed in this PR
This test-only change addresses the order-dependent apm outdated table-width flake tracked in #4773 by resetting cached console state between tests. Product behavior is unchanged.
Changes:
- Centralizes console resets in a helper that also clears the themed console singleton before and after each test.
- Extends the existing regression test to verify themed console cleanup during both fixture setup and teardown.
| File | Description |
|---|---|
| tests/integration/test_wave6_outdated_view_coverage.py | Adds assertions that the fixture clears the themed console singleton. |
| tests/conftest.py | Adds a shared reset helper and invokes it before and after each test. |
Review effort: Balanced
Daniel Meppiel (danielmeppiel)
deleted the
danielmeppiel-fix-4773-console-width
branch
November 22, 2026 19:32
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 22, 2026
Co-authored-by: Copilot App <[email protected]>
Merged
3 of 10 tasks
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.
Description
test_outdated_command.py::TestOutdatedCommand::test_long_package_name_folds_instead_of_clippingfails depending on shard order: it asserts an 80-column fold but sees a table about 124 columns wide.Root cause:
apm outdatedrenders throughcommands/_helpers._get_console, which isapm_cli.utils.themed_console._get_console. That returns a module singleton (themed_console._console), and Rich fixes a console's width when it is built. The autouse_reset_console_statefixture intests/conftest.pyresetsutils.console._console_instanceandrich._console, but notthemed_console._console. So the first test on an xdist worker that builds the themed console fixes its width for every later test on that worker. Evidence: CI job 137286964300 (#4758) and #4777 Shard 1, job 137290508485.Fix (test-only): the shared fixture now calls a
reset_console_singletons()helper, which also nullsthemed_console._consolebefore and after each test. Because the reset lives in the autouse fixture, it covers every test, not only the outdated one. No product code, CONFORMANCE or lifecycle files change.Credit: W2b and P3 also identified the themed singleton.
Issue and approved scope
Issue: Fixes #4773
Human scope-approval comment: test-only flake fix assigned by the QL VP under the inherited-red standing rule (#4773 is the tracked flake). No product behaviour changes.
Does this PR complete the issue, or what remains? It completes it.
Type of change
Testing
Regression guard:
tests/integration/test_wave6_outdated_view_coverage.py::TestOutdatedParallel::test_console_guard_resets_rich_singleton_before_and_afternow setsthemed_console._consoleto a mock and asserts the fixture nulls it before and after. That assertion fails on main's conftest.The order-dependent repro runs a probe first: a test that sets
COLUMNS=200and callsthemed_console._get_console(), followed by the outdated test, with-p no:xdist -p no:randomly. Results are posted in a PR comment.Lint:
uvx [email protected] checkandformat --checkon the changed files pass;scripts/check_test_assertions.pypasses;tests.quality.taxonomy --changedpasses for the committed files.Changelog
changelog.d/<pr>.<section>.md, holding one line: user-visible effect first, 25 words or fewer, ending with(#PR); breaking changes only under upgrade notes; no Highlights; no new lines under## [Unreleased]. Seechangelog.d/README.mdand.github/instructions/changelog.instructions.md.Spec conformance (OpenAPM v0.1)
CONFORMANCE.{md,json}regenerated