Now I have a python project, I write my unit-testing code in many of its folders, the tree looks like:
Project
├── module1
│ ├── submodule1
│ │ ├── base.py
│ │ ├── model.py
│ │ └── tests.py
│ ├── conn.py
│ ├── __init__.py
│ └── tests.py
├── errors.py
├── __init__.py
├── router.py
└── tests.py
You can see there are many tests.py
files in the projects, at root folder in modules. I use nose to help me do testing, When I want to test all of them, just run nosetests Project
at upper folder, everything works fine.
Then comes to my question: I have seen some projects like tornado, they put all test files in one folder so that it is clear to manage them (I guess), is that a better way than what I do currently, if yes, then why ? And according to the philosophy of Python, is there anything wrong in my way of doing test ?
Personnally, I prefer to store my test files into a specific subdirectory test
, yet I like to keep test and code very near, so I have test
subdirectories every where in my project.
Project
├── module1
│ ├── submodule1
│ │ ├── base.py
│ │ ├── model.py
│ │ └── test
│ │ └── submodule1_test.py
│ ├── conn.py
│ ├── __init__.py
│ └── test
│ └── module1_test.py
├── errors.py
├── __init__.py
├── router.py
└── test
└── errors_test.py
└── router_test.py
Very easy to make a packaging with avoiding all tests directories.