Pytest Operations

From NovaOrdis Knowledge Base
Jump to navigation Jump to search

Internal

Running pytest As a Module

python -m pytest

Running from Command Line, Automatically Detecting Tests

Install pytest as described here:

pytest Installation

Executing A Single Test

Executing a Single Test in a Module

pytest test_mod.py::test_func

Executing a Single Test in a Class

pytest test_mod.py::TestClass::test_method

Generate Report

./venv/bin/pip install pytest-html
pytest --html=~/tmp/report.html