support testing/linting module_utils code

This does not directly affect network because network has its own
solution for dealing with testing/linting module_utils code, but
it gets network to feature/code parity with the template and
other repos.

Defines a shell function in utils.sh - lsr_setup_module_utils -
that allows configuring a tox venv installed ansible to have
the repo module_utils code in the default pythonpath for the
venv, which allows testing and linting the module_utils code
without having to otherwise munge or mock the pythonpath.

Projects needing this functionality can set in `.travis/config.sh`
the variable `RUN_PYTEST_SETUP_MODULE_UTILS` to setup
module_utils/ for pytest, and `RUN_PYLINT_SETUP_MODULE_UTILS`
to setup module_utils/ for pylint.
This commit is contained in:
Rich Megginson 2020-04-01 15:19:59 -06:00 committed by Till Maas
parent 11a03f0ceb
commit dec163940e
6 changed files with 90 additions and 0 deletions

View file

@ -22,6 +22,8 @@ passenv = *
setenv =
PYTHONPATH = {toxinidir}/library:{toxinidir}/module_utils
LC_ALL = C
SRC_MODULE_UTILS_DIR = {envsitepackagesdir}/ansible/module_utils
DEST_MODULE_UTILS_DIR = {toxinidir}/module_utils
changedir = {toxinidir}/tests
covtargets = --cov={toxinidir}/library --cov={toxinidir}/module_utils
pytesttarget = unit