Keeping Your Source Organized

Just like the dinosaurs in Jurassic Park, Python codebases have a habit of breaking out from inside the fenced pens we try to create for them. One particularly vexing problem can be keeping project code organized. As time passes, code starts to live in places it shouldn’t and it can become increasingly difficult to find what files code should live in or where new code should be placed. In this section, we’ll explore a general strategy that uses Python’s built-in unittest module to keep a directory organized.

Maintaining Organization in a tests/ Directory

Many Python codebases contain tests to help verify that they are working correctly. Frequently, these tests are defined in a directory named tests/ at the top level ...

Get Intuitive Python 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.