Code-style tests

A third category of Ansible tests is the code-style category. These tests examine the syntax used in the Python files, ensuring a cohesive look across the code base. The code style enforced is defined by PEP8, a style guide for Python. More information is available in test/sanity/pep8/README.md. This style is enforced via the pep8 make target. If there are no errors, this target does not output any text; however, the return code can be verified. A return code of 0 means there were no errors:

Additional Python modules might be required to run these tests – the method for installing these will vary from system to system, and could typically be through use of the pip tool. On my CentOS 7 test system, I had to run the following command to be able to run this test: sudo yum install python2-packaging python2-pycodestyle.

If a Python file does have a pep8 violation, the output will reflect the violation:

pep8 errors will indicate an error code, which can be looked up for detailed explanations and guidance.