Skip to content

馃И test(docstring): pin what a nested handler restores - #759

Merged
gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:test-750-reentrancy-coverage
Aug 24, 2026
Merged

馃И test(docstring): pin what a nested handler restores#759
gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:test-750-reentrancy-coverage

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Aug 24, 2026

Copy link
Copy Markdown
Member

_annotation_state publishes three values on the config and restores what was there, so a nested process_docstring hands the outer call its own values back. The tests covered only the surviving build. Since bool renders the same whatever _typehints_module_prefix holds, a teardown restoring "" in place of the saved value passes the whole suite.

The unit test now puts the two objects in different modules and reads the prefix back inside the formatter, after the nested call returns. A clobbered restore shows up as ["", ""] where ["outer_mod", "outer_mod"] belongs. A second test drives the same re-entry through a real build, against the real sphinx.config.Config: deleting an attribute that was never set raises AttributeError there, while the create_autospec(Config) mock that tests/test_init.py shares treats it as a silent no-op. That gap has the shape of the crash in #750, so the fix deserves a test running against the object that broke. 馃攣

The regression test that came with tox-dev#758 only proved the build survives
re-entry. Restoring the wrong values passes it just as well: bool renders
the same whatever module prefix the outer call ends up with, so a teardown
that clobbered the state went unnoticed.

The unit test now reads the module prefix back inside the formatter, after
the nested call returns, and a second test drives the same re-entry through
a real build. That one exercises the actual Config, where deleting an
attribute that was never set raises, unlike the autospec mock the unit
tests share.
@gaborbernat
gaborbernat merged commit 7853f2e into tox-dev:main Aug 24, 2026
10 checks passed
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