Skip to content
Advertisement

What’s the idea behind pytest-cache?

pytest-cache

It seems to be a tool to cache func/args->result pairs and even persist them between testsuite-runs. Which seems like a great idea to speed things up. However I haven’t noticed any mention of automatically detecting a change of a function source code and invalidating corresponding cache entries. That seems to defeat the purpose of running the test suite, because the tested code changes are not going to be reflected.

Advertisement

Answer

pytest-cache does two things:

  • offer a mechanism through which other plugins can get/set values via config.cache.get|set. This is used by pytest-pep8 and pytest-flakes for example to store the mtime of the last check to avoid re-checking files all the time.

  • store test failures so that you can run --lf to run only the last failures and --ff to run the last failures first, then the rest of the tests.

The functionality is bound to move to the core with pytest-2.7 (not released as of today) or a subsequent release.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement