Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preventing pytest from creating .cache directories in Pycharm

Tags:

I'm using Pycharm for this years Advent of Code and I'm using pytest for testing all of the examples and output.

I'd prefer it if pytest didn't create the .cache directories throughout my directory tree. Is there anyway to disable the creation of .cache directories when tests fail?

like image 551
labarna Avatar asked Dec 10 '17 22:12

labarna


People also ask

What is Pytest cache?

The pytest-cache plugin adds a config. cache object during the configure-initialization of pytest. This allows other plugins, including conftest.py files, to safely and flexibly store and retrieve values across test runs because the config object is available in many places.

Where is PyCharm cache?

By default, PyCharm stores user-specific files for each IDE instance (configuration, caches, plugins, logs, and so on) in the user's home directory.


1 Answers

There are two basic options:

  • disable the caching altogether (the caching is done with the cacheprovider plugin):

    pytest -p no:cacheprovider 

    -p is used to disable plugins.

  • changing the cache location by tweaking the cache-dir configuration option (requires pytest 3.2+)

    Sets a directory where stores content of cache plugin. Default directory is .cache which is created in rootdir. Directory may be relative or absolute path. If setting relative path, then directory is created relative to rootdir.

Here is a sample PyCharm run configuration with the no:cacheprovider:

enter image description here

like image 89
alecxe Avatar answered Oct 08 '22 07:10

alecxe