# Vela Testing ## Sanity checks and tests The Python codebase is PEP8 compliant with the exception of a 120 character line length. We run reorder-python-import, black and flake8 against the code base excluding "ethosu/vela/tflite/" and "ethosu/vela/ethos\_u55\_regs" directories because they are auto-generated by third party tools. Those tools are run using [pre-commit framework](https://pre-commit.com/). The configuration file is .pre-commit-config.yaml ### Install tools To install pre-commit, run the following: ```bash pipenv install -e . --dev ``` After the installation, pre-commit is available in the virtual environment. Besides pre-commit, we install also: * pytest: testing framework * pytest-cov: code coverage plugin for pytest ### Install the pre-commit hook To ease the development, we can run those sanity checks before committing the code. To install the git hook, run: ```bash $ pre-commit install pre-commit installed at .git/hooks/pre-commit ``` The checks will be run before the commit: if one of them fails, you need to fix the code to make the checks pass. ### Run the tests Tests and test coverage can be run using pre-commit framework. ```bash $ pre-commit run pytest ... $ pre-commit run pytest-cov ``` ### Run the sanity checks Those checks can be run manually. This can be achieved running the following ```bash $ pre-commit run reorder-python-imports --all-files ... $ pre-commit run flake8 --all-files ... $ pre-commit run black --all-files ``` If you don't specify anything after run, it will execute all the checks. ```bash $ pre-commit run --all-files Reorder python imports...................................................Passed black....................................................................Passed flake8...................................................................Passed pytest...................................................................Passed ... ... ```