caching default algo fixture#414
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #414 +/- ##
=======================================
Coverage 98.51% 98.51%
=======================================
Files 33 33
Lines 1948 1948
=======================================
Hits 1919 1919
Misses 29 29 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
m-goggins
left a comment
There was a problem hiding this comment.
I like copying so that we aren't modifying the algorithm. One thing to note if we run into an issue like this again, it seems that switching the order of the caching and pytest.fixture also solves the problem. In 8.4.0, it seems that the pytest.fixture decorator needs to be first in order to be recognized if there are multiple decorators.
When I just switch the order of the decorator, I get these 4 errors. ================================================================ short test summary info =================================================================
FAILED tests/unit/routes/test_link_router.py::TestMatch::test_no_match - pydantic_core._pydantic_core.ValidationError: 4 validation errors for Algorithm
FAILED tests/unit/routes/test_link_router.py::TestMatch::test_match - pydantic_core._pydantic_core.ValidationError: 4 validation errors for Algorithm
FAILED tests/unit/routes/test_link_router.py::TestMatchFHIR::test_no_match - pydantic_core._pydantic_core.ValidationError: 4 validation errors for Algorithm
FAILED tests/unit/routes/test_link_router.py::TestMatchFHIR::test_match - pydantic_core._pydantic_core.ValidationError: 4 validation errors for Algorithm
================================================= 4 failed, 275 passed, 1 skipped, 20 warnings in 2.40s ================================================== |
|
Oh, I see. On my branch I just switched the order but left |
## Description Replacing lru_cache decorator on default_algorithm fixture with a scope=session for reuse. Updating a handful of tests in test_link.py to modify a copy of the default_algorithm object, rather than the original, so we don't break subsequent tests using that same fixture. ## Additional Notes The latest release of [pytest, 8.4.0, made changes](https://docs.pytest.org/en/stable/changelog.html#pytest-8-4-0-2025-06-02) to how fixtures are recognized and loaded. Using an lru_cache decorator on top of a pytest.fixture, is now causing the harness to not see it.
Description
Replacing lru_cache decorator on default_algorithm fixture with a scope=session for reuse. Updating a handful of tests in test_link.py to modify a copy of the default_algorithm object, rather than the original, so we don't break subsequent tests using that same fixture.
Additional Notes
The latest release of pytest, 8.4.0, made changes to how fixtures are recognized and loaded. Using an lru_cache decorator on top of a pytest.fixture, is now causing the harness to not see it.
<--------------------- REMOVE THE LINES BELOW BEFORE MERGING --------------------->
Checklist
Please review and complete the following checklist before submitting your pull request:
Checklist for Reviewers
Please review and complete the following checklist during the review process: