Cache name resolutions#369
Merged
Merged
Conversation
34366ac to
76ed414
Compare
To avoid resolving the allowed hostnames once per test, cache the results in a shared dict. This should result in one set of resolutions per pytest run (or test worker, under pytest-xdist). I also refactored the plugin to use Stash, which was introduced in pytest 7.0.0, rather than set attributes on config.
53acc15 to
2bcdf8c
Compare
miketheman
reviewed
Aug 21, 2024
Owner
miketheman
left a comment
There was a problem hiding this comment.
Very cool stuff - I didn't know about stash, that's much nicer than the __... stuff I was doing before.
Can you conceive of a test to add that confirms the resolution cache is working?
b025860 to
0ed6819
Compare
|
Code Climate has analyzed commit f2704d5 and detected 0 issues on this pull request. View more on Code Climate. |
f2704d5 to
0ed6819
Compare
Contributor
Author
|
@miketheman I think I've addressed all your feedback. I settled on monkey patching Interestingly, it looks like pre-commit.ci's autocommit bypasses workflow approval. (Sorry about the many notifications...) |
miketheman
approved these changes
Sep 7, 2024
Owner
miketheman
left a comment
There was a problem hiding this comment.
@twm Thanks for putting in the effort!
Contributor
Author
|
Thank you for the review! |
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.
To avoid resolving the allowed hostnames once per test, cache the results in a shared dict. This should result in one set of resolutions per pytest run (or test worker, under pytest-xdist). I did this in a backward-compatible manner by introducing an optional parameter to the
socket_allow_hosts()andnormalize_allowed_hosts()functions as they appear to be public API, albeit undocumented.I also refactored the plugin to use Stash, which was introduced in pytest 7.0.0, rather than set attributes on Config. If you want to keep support for
pytest>=6.2.5I can back that bit out, I just thought it improved clarity.