馃И test(docstring): pin what a nested handler restores - #759
Merged
gaborbernat merged 1 commit intoAug 24, 2026
Conversation
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.
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.
_annotation_statepublishes three values on the config and restores what was there, so a nestedprocess_docstringhands the outer call its own values back. The tests covered only the surviving build. Sinceboolrenders the same whatever_typehints_module_prefixholds, 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 realsphinx.config.Config: deleting an attribute that was never set raisesAttributeErrorthere, while thecreate_autospec(Config)mock thattests/test_init.pyshares 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. 馃攣