How to test single file under pytest

simonzack picture simonzack · Jan 17, 2016 · Viewed 44.3k times · Source

How do you test a single file in pytest? I could only find ignore options and no "test this file only" option in the docs.

Preferably this would work on the command line instead of setup.cfg, as I would like to run different file tests in the ide. The entire suite takes too long.

Answer

Bryant picture Bryant · Jan 17, 2016

simply run pytest with the path to the file

something like

pytest tests/unit/some_test_file.py