You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"""Call cache_clear on every cache_function, after every test run."""
forfunctioninCACHED_FUNCTIONS:
function.cache_clear()
yield
this is an issue for me because i have teardown code for my tests that rely on the caches. it would be nice if the teardown was a trylast hook instead:
I'm open to either implementation, as they both fulfill the spirit. I'm leaning towards pytest_runtest_setup, since it'd be closer scoped to when we care to bust caching (actual test).
Huh, I think hookwrapper=True is actually unintentional, since there's no wrapping going on. TIL
Please put up a PR, the existing unit tests should correctly test this refactor.
(thanks for this plugin btw, it uncovered so many issues with our tests that previously went completely undetected. this should be built into pytest)
Thanks for the kind words! Credit should go to my colleague for their pytest wizardry.
Once upon a time I was hurt by a stupid flaky test that I wrote (like you), complained about it while doing absolutely nothing, was gifted a solution from above, and now I repay what I can by maintaining this project 😆
currently the teardown for clearing the caches happens first:
pytest-antilru/pytest_antilru/main.py
Lines 78 to 84 in e742b9c
this is an issue for me because i have teardown code for my tests that rely on the caches. it would be nice if the teardown was a
trylast
hook instead:or perhaps it could run during setup, to guarantee that the cache is present during all other teardowns from previous tests:
(thanks for this plugin btw, it uncovered so many issues with our tests that previously went completely undetected. this should be built into pytest)
The text was updated successfully, but these errors were encountered: