Skip to content

tests: Isolate absence-content editor cleanup assertions - #459

Merged
halfline merged 2 commits into
mainfrom
publish/editor-cleanup-test-isolation-20260902T214353Z
Sep 2, 2026
Merged

tests: Isolate absence-content editor cleanup assertions#459
halfline merged 2 commits into
mainfrom
publish/editor-cleanup-test-isolation-20260902T214353Z

Conversation

@halfline

@halfline halfline commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Batch storage tests verify that absence-content builders close their temporary
line editors after normal completion and when construction raises an
exception.

Both assertions replace LineEditor.close on the class. Cyclic garbage
collection can finalize unrelated editor objects while that replacement is
active, causing their cleanup calls to increase the local counter and make the
test fail nondeterministically.

This pull request keeps a strong reference to each builder's editor and
attaches the counter only to that instance. The tests continue to exercise the
production context-manager behavior without observing cleanup from unrelated
objects.

Validation:

  • uv run pytest -n auto
  • uv run ruff check src tests scripts
  • uv run python scripts/check_translations.py
  • uv run python scripts/check_dead_code.py
  • uv run python scripts/check_type_hygiene.py
  • uv run mypy

The batch storage tests verify that absence-content builders close their
temporary line editors after normal completion and exceptions.

The exception-path assertion replaces the close method on the editor class.
Cyclic garbage collection can finalize unrelated editors while that
replacement is active, so their cleanup calls can inflate the counter and
fail continuous integration nondeterministically.

This commit addresses that nondeterminism by retaining the exception-path
builder's editor and attaching the close counter only to that instance.

The final commit will apply the same isolation to the normal completion
path.
The exception-path absence-content cleanup test now observes only the
editor created for its builder. The normal completion test still replaces
the close method on the editor class.

Cyclic garbage collection can finalize unrelated editors while the
completion test's replacement is active, leaving its close counter
vulnerable to the same nondeterministic overcount.

This commit resolves the remaining nondeterminism by retaining the
completion builder's editor and attaching the close counter to that
instance. The module alias used to reach the editor class becomes
unnecessary and is removed.

Both absence-content cleanup paths now observe only the resource they
create, completing the test-isolation fix.
@halfline
halfline merged commit bb98be1 into main Sep 2, 2026
12 checks passed
@halfline
halfline deleted the publish/editor-cleanup-test-isolation-20260902T214353Z branch September 2, 2026 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant