Tests and Linting

This page describes tests and linting of the API (python) and how you can run tests locally as well as how the GitHub actions tests your code.

GitHub actions (CI/CD)

The pull requests on master branches will be tested using a Github Actionsarrow-up-right CI/CD pipeline. The tests are as follows:

  • pytest checks if the unit-tests are successful

  • flake8 does the following linting checks

Running tests and linting locally

triangle-exclamation
pip install flake8-import-order
pip install flake8-blind-except
pip install flake8-builtins
pip install flake8-docstrings
pip install flake8-rst-docstrings
pip install flake8-logging-format
tox
pytest
circle-info

The way below runs a LOT faster due to it not having to set up a virtualenv

# Go to the helpers repo and install requirements.txt

alias farm-lint="flake8 . --ignore=D210,D100,D104,D401,D202,E202,E201,I201 --show-source --enable-extension=G --max-line-length=140 --max-complexity=7 --count"
alias farm-test="pytest -v -s" # This one is optional

farm-lint # will now run flake8 linting with the correct settings
farm-test # will now run pytest tests with two nice verbosity flags.

Cyclomatic Complexity References

Last updated