-
Notifications
You must be signed in to change notification settings - Fork 740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[pytest] Improve 'cached' decorator #3112
Merged
Merged
Conversation
This file contains 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
This pull request introduces 2 alerts when merging a7aeaf09311c7d51efbc1d8213931c16981ae541 into b4b6d21 - view on LGTM.com new alerts:
|
lolyu
force-pushed
the
refact_cache
branch
3 times, most recently
from
March 9, 2021 14:08
6d21d9e
to
bf14562
Compare
Signed-off-by: Longxiang Lyu <[email protected]>
/AZP run |
Azure Pipelines successfully started running 1 pipeline(s). |
bingwang-ms
reviewed
Mar 10, 2021
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
bingwang-ms
approved these changes
Mar 10, 2021
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Signed-off-by: Longxiang Lyu <[email protected]>
/AZP run |
Azure Pipelines successfully started running 1 pipeline(s). |
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.
Description of PR
Summary:
Fixes # (issue)
Type of change
Approach
What is the motivation for this PR?
cached
decorator has limitations that it only supports being used for methods of classAnsibleBaseHost
and its derivatives.FactsCache
returnsNone
in either theFactsCache
fails to find cached facts or the decorated function returnsNone
.tests/common/utilities
that try to retrieve host variables share a similar call pattern that the arguments all havehostname
defined and have the same logic to check the inventory in cache reading or add the inventory in cache writing.How did you do it?
zone_getter
argument to thecached
decorator to let it receives a customizable function to get the zone.FactsCache
fails to find cached facts, let it returnsFactsCache.NOTEXIST
instead ofNone
(None
is a valid return from the decorated function)after_write
andbefore_read
to thecached
decorator to let it have extra functionalities to process the facts after the cache reading/before the cache writing.How did you verify/test it?
Any platform specific information?
Supported testbed topology if it's a new test case?
Documentation