Getting Started
Introduction
The pytest-logikal package provides an improved pytest environment which automatically runs a broad range of checks:
Typing checks (via mypy and pytest-mypy)
Linting (via Pylint)
Code style checks (via isort, pycodestyle and pydocstyle)
Coverage checks (via coverage.py and pytest-cov)
Security checks (via Bandit)
License checks (via pip-licenses)
Requirements lockfile checks (via pyorbs, when applicable)
Documentation checks (via logikal-docs, when applicable)
Package build checks (via build, when applicable)
The checks are configured to be strict, and all checks and tests are distributed across multiple CPUs by default (via pytest-xdist).
Installation
You can simply install pytest-logikal
from pypi:
pip install pytest-logikal
In addition to providing an opinionated default configuration, it also makes the output of the various pytest plugins more consistent.
Extras
browser
The browser
extra installs Selenium and provides the
browser
fixture for convenient browser automation in
tests:
pip install pytest-logikal[browser]
django
You may also use the django
extra to install the necessary packages, plugins and fixtures for
testing Django projects:
pip install pytest-logikal[django]
This will additionally install and configure django-stubs, pylint-django, pytest-django and pytest-factoryboy.
When using the django
extra you must also specify the Django settings module and mypy plugin
path in your pyproject.toml
file as follows:
[tool.pytest.ini_options]
DJANGO_SETTINGS_MODULE = 'project.settings.testing'
[tool.mypy]
plugins = ['mypy_django_plugin.main']
Configuration
You shall not change the standard, default configuration when working on Logikal software.
Nonetheless, regular configuration options for the various tools in the pyproject.toml
file
will be typically respected. Additionally, you can extend the allowed licenses and packages for
the license checker plugin as follows:
[tool.licenses]
extend_allowed_licenses = ['Allowed License']
[tool.licenses.extend_allowed_packages]
package = 'Package License'
You can also override the default licenses and packages (instead of extending them) via the
tool.licenses.allowed_licenses
and tool.licenses.allowed_packages
options.