September 2017
Intermediate to advanced
222 pages
5h 1m
English
The utility of having __init__.py files in every test subdirectory of a project confused me for a long time. However, the difference between having these and not having these is simple. If you have __init__.py files in all of your test subdirectories, you can have the same test filename show up in multiple directories. If you don’t, you can’t. That’s it. That’s the effect on you.
Here’s an example. Directory a and b both have the file, test_foo.py. It doesn’t matter what these files have in them, but for this example, they look like this:
| | def test_a(): |
| | pass |
| | def test_b(): |
| | pass |
With a directory structure like this:
| | dups |
| | ├── a |
| | │ └── test_foo.py |
| | └── b |
| |
Read now
Unlock full access