-
Notifications
You must be signed in to change notification settings - Fork 480
Docs: Depends import gotcha #8215
Copy link
Copy link
Closed
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationpending-releaseFix or implementation already in dev waiting to be releasedFix or implementation already in dev waiting to be released
Description
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationpending-releaseFix or implementation already in dev waiting to be releasedFix or implementation already in dev waiting to be released
Type
Fields
Give feedbackNo fields configured for issues without a type.
Projects
StatusShow more project fields
Coming soon
What were you searching in the docs?
Absolutely loving that new Depends in the REST API handler, massive improvement to how we've done things.
Something we've noticed is when testing with dependency overrides, the imports for the dependency function have to match exactly between the test file and the handler file.
For example doing dependency overrides with get_config in a test with imports like this (despite it being the same actual function) means the override won't be applied and will instead resolve the actual get_config.
what you need to do would be
This is a funky gotcha that's not immediately obvious or debuggable, so a note in the docs could be helpful.
Is this related to an existing documentation section?
https://docs.aws.amazon.com/powertools/python/latest/core/event_handler/api_gateway/#testing-with-dependency-overrides
How can we improve?
I think having a call-out about this gotcha could be helpful in the testing section.
Got a suggestion in mind?
When using
dependency_overrides, the imported dependency reference in your test must exactly match the one used by the handler. (With sensible example, like what I've provided)Acknowledgment