Django doctests in views.py

Posted by Brian M. Hunt on Stack Overflow See other posts from Stack Overflow or by Brian M. Hunt
Published on 2010-03-04T15:39:23Z Indexed on 2010/06/12 21:13 UTC
Read the original article Hit count: 368

Filed under:
|
|
|

The Django 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

© Stack Overflow or respective owner

Related posts about python

Related posts about django