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.
The default cache directory has been renamed from .cache to .pytest_cache after community feedback that the name .cache did not make it clear that it was used by pytest. According to the docs, pytest-cache was integrated in pytest 2.8, and the plugin provides two command line options to rerun failures from the last pytest invocation:
For cleanup (usually not needed), a --cache-clear option allows to remove all cross-session cache contents ahead of a test run. Since pytest version 3.8.1 (2018-09-22) .pytest_cache directory contains its own .gitignore file and is automatically ignored by Git. ( see more)
Pytest is quick and easy to learn. Pytest can choose to run a particular test method or all the test methods of a particular test file based on conditions. Pytest is capable of skipping a few test methods out of all the test methods during test execution. Pytest can be used to test a wide range of applications on API, database and so on.
The advantages of pytest framework are listed below − Pytest is capable of executing multiple test cases simultaneously, thereby reducing the execution duration. Pytest is capable of skipping a test method from a group of test methods during execution.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With