Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pytest: Only run linter checks (pytest-flake8), don't run tests

Tags:

python

pytest

I'm using the pytest-flake8 plugin to lint my Python code. Everytime I run the linting like this:

pytest --flake8

In addition to the linting, all tests are run. But I would like to run the linter checks only.

How can I configure pytest so it only lints the code but skips all my tests, preferrably via commandline (or conftest.py) - without having to add skip markers to my tests?

like image 678
Wolkenarchitekt Avatar asked Oct 19 '18 09:10

Wolkenarchitekt


2 Answers

flake8 tests are marked with the flake8 marker, so you can select only those by running:

pytest --flake8 -m flake8

like image 146
bandela Avatar answered Sep 28 '22 17:09

bandela


Pytests --ignore <<path>> option also works well here if all of your tests are in one directory.

I usually hide this behind a make command. In this case my Makefile and tests directory are both at the root of the repository.

.PHONY: lint

lint:
    pytest --flake8 --ignore tests
like image 45
ryanburda Avatar answered Sep 28 '22 18:09

ryanburda