Repository navigation
fix: reject a provider named like the container fixture in expose() - #69
Merged
Merged
Conversation
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.
Closes #67
expose()now raisesValueErrorwhen a provider's attribute name equals thecontainer_fixturename in use (di_containerby default, or whatever is passed). Before this, the generated fixture replaced the user's container fixture, every generated fixture then depended on itself, and each test failed with a recursive dependency error that did not point at the cause.The error message names the group, the attribute, and the container fixture, and suggests renaming the provider or passing a different
container_fixture.Design notes:
_collect_fixtures, next to the existing duplicate-name check, so it runs before anything is installed on the module and can name the offending group._collect_fixturesgains a keyword-onlycontainer_fixtureargument defaulting todi_container, matchingexpose().ValueErrorfor consistency with the duplicate-name collision. The modern-di exception types are about container registration and do not fit a fixture naming problem.di_containeris still allowed when a differentcontainer_fixtureis passed, since nothing collides in that case.Tests: three new cases in
tests/test_expose.py(default name, custom name, and the no-collision case with a custom name). The first two failed before the fix. README'sexposesection mentions the new error.