Pytest Installation

From NovaOrdis Knowledge Base
Revision as of 20:52, 25 July 2023 by Ovidiu (talk | contribs) (→‎Overview)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Internal

Overview

pytest is installed in a virtual environment and then used from that virtual environment.

Add this to requirements.txt:

pytest == 7.1.2

Then


For your project, configure direnv to set PATH to give priority to your virtual environment bin directory. In .envrc:

PATH_add "./src/main/python/venv/bin"

Then install pytest with that pip:

pip install -U pytest

Given the direnv setup, pytest will automatically become available:

which pytest

.../src/main/python/venv/bin/pytest

Check for pytest from Script

pytest --version 2>/dev/null 1>&2 || fail "pytest not installed, cannot execute python tests"