test: lock in instance-attribute reads in api_bootstrapper_config#57
Merged
Merged
Conversation
Port the regression test from litestar-sqlalchemy-template#32. The production bug fixed there (api_bootstrapper_config reading the module -global `settings` singleton instead of `self`) is already absent here, but there was no test guarding against it being reintroduced. The test constructs a non-singleton Settings instance and asserts its api_bootstrapper_config reflects that instance, not the global. Co-Authored-By: Claude Opus 4.8 (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.
Context
Ports the regression test from litestar-sqlalchemy-template#32.
That PR fixed a bug where
Settings.api_bootstrapper_configbuilt its config from the module-globalsettingssingleton instead ofself, so any non-singletonSettingsinstance (or access during the singleton's own construction) silently produced the singleton's values.State in this repo
The production code here already reads
self.*— the bug is absent. What was missing was a test guarding against it being reintroduced. This PR adds only that test.Test
tests/test_settings.pyconstructsSettings(service_name="custom-service", service_version="9.9.9")and assertsapi_bootstrapper_configreflects the instance rather than the global. Passes GREEN against the current (correct) code; would fail if theself.*reads ever regressed tosettings.*.ruff format --check,ruff check --no-fix, andty checkall pass on the new file.🤖 Generated with Claude Code