I have built my website in Django. And like any other django project I have got apps inside the project root directory and some special folders like(extensions a.k.a custom django command extensions). With an app, we dont have any problem with having testcases. "tests.py" inside the app directory will be the solution. But for a special folder(which is not an app or which doesn't have a models.py) where do I place the testcases. I tried placing the tests.py inside the extensions directory and it said the directory is not a model and unable to run the tests. HOw do I solve this? How can I have a proper placement of testcases related to non-apps?
+1
A:
I think it will work to put them in a tests/
directory at the project level.
If, for some reason, it doesn't then try creating an empty models.py
in your extensions directory.
Van Gale
2009-03-04 13:50:59
Empty models.py will solve the issue but its not a good practice to have a file which does nothing right! And tests/ directory at the project level should hold project level tests. My case is evaluating only certain tests related to a particular directory(extensions in my case).
Maddy
2009-03-04 14:59:14
Needing an empty models file is a standard Django problem/feature :) It's because of the way Django tests for app directories, just as Python itself needs an __init__.py file for packages even if the file is empty.
Van Gale
2009-03-04 15:07:57
Yes, empty models.py is the right solution. It doesn't "do nothing" - it says "this is a Django app." Same way an empty __init__.py says "this is a Python package." Nothing wrong with that.
Carl Meyer
2009-03-04 16:06:29