Chapter 9

Looking After Your Lint

THIS CHAPTER IS covers the routine housekeeping tasks for your application and the tools you need to help keep your code in check. The creator of Python himself, Guido, along with some other key developers of the language, encourage Python developers to follow certain style guidelines. These guidelines and other suggestions and information about the language are conveyed to the global Python community via Python Enhancement Proposal (PEP) documents. Guido created the famous PEP-8 document in which most of the Python style guidelines are defined. Elements such as indentation, naming conventions, instance properties, and many other code factors have specific instructions in PEP-8. Following these suggestions makes your code more readable and accessible to Python developers around the world.

Fortunately, tools have been developed to increase confidence in your code meeting these guidelines. Pylint—a Python package that can be installed using Pip on the command line—offers a convenient way to check your code and suggests where your code has not met expectations. Fix the errors Pylint finds to ensure your application's code meets the expectations of the language and the Python development community.

Finally, this chapter tells you how to ensure your application’s code has full code coverage. Unit tests are a vital part of your testing, but if areas of your application aren’t covered by tests then you are leaving yourself vulnerable to a defect in ...

Get Testing Python: Applying Unit Testing, TDD, BDD and Acceptance Testing now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.