Pytest Installation: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 24: Line 24:


.../src/main/python/venv/bin/pytest
.../src/main/python/venv/bin/pytest
</syntaxhighlight>
=Check for pytest from Script=
<syntaxhighlight lang='bash'>
pytest --version 2>/dev/null 1>&2 || fail "pytest not installed, cannot execute python tests"
</syntaxhighlight>
</syntaxhighlight>

Revision as of 01:33, 9 June 2022

Internal

Overview

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

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"