pytest ignore venv when called from shell without pytest.ini file

Viewed 702

I am trying to use pytest within my Mac's terminal. I do not have a pytest.ini set up, and do not wish to make one at this time.

When I run the command pytest alone, it prints warnings (DeprecationWarning) for multiple site packages within my virtual environment (named venv, located within my project's root directory).

venv/lib/python3.6/site-packages/eventlet/patcher.py:1
  /path/to/venv/lib/python3.6/site-packages/eventlet/patcher.py:1: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
    import imp

I would like to ignore the venv/ directory when running pytest, so my warnings are relevant to my project only.

How can I not run pytest on my virtual environment?


What I Have Tried

I have tried multiple versions of the --ignore flag:

pytest --ignore=venv
pytest --ignore=./venv/
pytest --ignore="venv/*"
pytest --ignore="./venv/*"

(source)

And using -k

pytest -k 'not venv'

(source)


What I Have Read

--disable-pytest-warnings: I still want other warnings to be displayed

--pythonwarnings ignore::DeprecationWarning seems too generic (what if one of my project files uses a deprecated module)

--pythonwarnings ignore::DeprecationWarning:some_package.*: is too manual (lots of my site packages generate warnings)


Versioning

  • macOS Mojave v10.14.3
  • Python 3.6.5
  • pytest==5.3.5
0 Answers
Related