On 5/20/07, Sandro Dentella <[EMAIL PROTECTED]> wrote:
>
> Hi again!,
>
>   some "easy" questions to use tests in the best way.
>
>   1. 'manage.py test' finds unittest in tests.py *and* models.py. It doesn't
>      seem to find docstring other that in tests.py. I pasted the Animal
>      example in a model but no test was run till I put it into tests.py.
>
>      Am I mis-interpreting the docs where they say "the test utility will
>      find this docstring"  or am I missing something?

The test utility does exactly the same thing as the standard Python
doctest tools, so the Python doctest documentation [1] is your best
guide here.

The most likely culprit will be the exact manner in which your test
docstring is defined. doctest is fussy about where docstrings are
located, and if they aren't in the expected location, they won't get
found and run. For example, the docstring must be the very first thing
in the file to be identified as the module docstring - if there is
anything before the module documentation, the docstring won't get
processed by doctest.

There are ways to help doctest find these strings - investigate the
__test__ module variable for more details.

>   2. tests.py is runs for each application, but my code is composed
>      obviously of general libraries, extensions to widgets, templatetags and
>      so on.
>
>      Where is the reccomended place to put tests for these parts and does
>      'manage test' provide some hooks for these or I should run these tests
>      separately?

For doctests, best practice is to use the __test__ module variable in
tests.py. See [1] for more details.

For unittests, best practice is to put 'from other.test.location
import *' in your tests.py file. This will pull any tests in the
'other.test.location' module into tests.py, where they can be
identified and executed.

[1] http://docs.python.org/lib/module-doctest.html

Yours,
Russ Magee %-)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to