On 8/10/07, patrickk <[EMAIL PROTECTED]> wrote:
>
> here are a couple of questions:
> 1. where to define the testing? in models.py or in tests.py? I´d like
> to seperate the testing from models.py, so how can I write doctests
> in a seperate file (the example in the django documentation only
> explains seperate unit-testing)?

Django will look for doctests and unit tests in both models.py and tests.py.

> 2. can I make a test-directory (and does that make sense) for all my
> tests or do I have to use the application-directories? within
> django_src, there´s a directory called "tests" for example.

Yes, in a couple of ways.

For unit tests - make a tests directory, put all your tests in that
directory (e.g., first_test.py), then in __init__.py, put 'from
first_test import *'.

Alternatively, in tests.py, define a suite() method that constructs a
unit test suite. See the Python documentation on building test suites
for more details.

For doctests - in tests.py, define a __test__ dictionary:

from some_location import first_test_string

__test__ = {
   'first_test': first_test_string
}

in this context, first_test_string is a doctest string that has been
imported from another location.

These tricks are all part of standard Python doctest/unittest testing.
Check out the Python docs for more details. The only Django specific
parts is the initial search - searching the models module and tests
module of each installed application for tests.

> 3. where do I find some examples (besides the django docs)?

Django itself is a pretty good example. Between the modeltests,
regression tests, and contrib app tests, Django has a very
comprehensive test suite, that provides all sorts of detailed examples
of how to set up and use tests.

> 4. does anyone know about a simple "how-to" on testing? something
> like "step 1: setup the testing-database", "step 2: create a test-
> directory (or use the app-dir or whatever)" ... ?

The steps are really just:
- write the tests, in locations that they will be found
- run the tests with ./manage.py test

However, I'm happy to improve on any area that you think the
documentation is inadequate. Suggestions are welcome.

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 django-users@googlegroups.com
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