The Django 1.4 documentation on tests states:
For a given Django application, the test runner looks for doctests in two places:
The
models.py
file. You can define module-level doctests and/or a doctest for individual models. It's common practice to put application-level doctests in the module docstring and model-level doctests in the model docstrings.A file called
tests.py
in the application directory -- i.e., the directory that holds models.py. This file is a hook for any and all doctests you want to write that aren't necessarily related to models.
Out of curiosity I'd like to know why Django's testrunner is limited to the doctests in models.py
, but more practically I'd like to know how one could expand the testrunner's doctests to include (for example) views.py
and other modules when running manage.py test
.
I'd be grateful for any input.
Thank you.
Brian
Django's native testing system is based on
unittest
package. So it is not as powerful as it can be.I recommend you using nose that is backward-compatible
unittest
on steroids. Use it along with Django test runner that uses nose. You can customize nose in many ways including pointing it to custom test locations using-m
flag.