Chapter 2: Testing Conventions
Alfredo Deza
There are specific unwritten rules for testing in Python that are followed by most projects and are supported by tooling. Most tooling (like test runners) allows you to configure them to adapt to whatever structure you want, but understanding the conventions makes it easier for the tools and project collaborators. The least amount of surprises, the better!
In this chapter, I go into details on file layouts, directories, and naming conventions. Test runners like pytest benefit from these conventions for automatic discovery, which is how tests are found and later executed.
The first time I found myself writing tests for a small script I created, I wasn’t entirely sure where to place them and if I needed ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access