On Fri, Jul 17, 2009 at 9:56 AM, Joshua Partogi<[email protected]> wrote:
> Hi Russ,
>
> To expand this question. Do we use unittest for testing forms? Because from
> what I see in the code, doctest only tests your model. CMIIW.

I shall. I don't know where you got that idea. :-)

doctests are just a way of expressing tests. It has no inherent
strengths, weaknesses or ties to model testing. It's just a way of
testing based on a mock shell - i.e., "If I run X at the python
prompt, I expect to see Y". You can do this with models, with forms,
or anything else that can be invoked as a Python command.

You can also use unittest to do exactly the same thing. The assertion
facilities for unit tests are a little easier to use (since it isn't
just based on string checking), but fundamentally, a unittest is just
a way to bundle a series of commands whose output can then be asserted
for validity.

Django's TestCase provides a few extra helpful bits for web app
testing - such as a built in test client, fixture loading, etc - but
that's only because it's easier to subclass unittest.TestCase than it
is to subclass the doctest framework.

In short, use whatever you find convenient. Both doctest and unittest
are valid and useful testing frameworks. In my experience, doctests
are usually easier to write initially, but unittests prove more useful
in the long term - but that's entirely subjective. YMMV.

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