feat: "Lazy load" VCR to reduce plugin overhead #146
Merged
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
This PR defers importing
_vcr
inplugin.py
until thevcr
fixture is invoked with a vcr-marked test. Themerge_kwargs
helper has been moved toutils.py
to allow importing it independently of the VCR modules required by_vcr.py
. VCR object imports are now guarded usingif TYPE_CHECKING
.To verify the performance improvement, I compared the results of running the same dummy test case with and without the vcr mark. I averaged results from running pytest 20 times, removing
__pycache__
and.pytest_cache
between runs. Here is a summary of the results:pytest_recording
version@pytest.mark.vcr
RuntimeThe results show a significant improvement in the runtime of unmarked tests, while the runtime of tests marked with
@pytest.mark.vcr
remains comparable to the previous version.Checklist