Overview - Test file and function naming conventions
What is it?
Test file and function naming conventions are rules about how to name your test files and test functions so that the testing tool can find and run them automatically. In pytest, test files usually start with 'test_' or end with '_test.py', and test functions start with 'test_'. These conventions help organize tests clearly and make running tests easier. Without these rules, tests might be missed or cause confusion.
Why it matters
Naming conventions exist so pytest can automatically discover and run your tests without extra setup. If you don't follow these rules, your tests might not run, leaving bugs hidden. This slows down development and reduces confidence in your code. Good naming also helps teams understand what each test does and where to find it quickly.
Where it fits
Before learning naming conventions, you should understand what tests are and how pytest runs tests. After this, you can learn about writing test assertions and organizing tests into classes or modules.