Perhaps I'm missing something, but when I run "manage.py test", the
system sets up a test database....

So you should be able to create all the model elements you need, and
save them and change them -- whatever.

In fact, what I do is during the setUp(...) routine, I add my "stock"
test data. It'll create 1000ish records with proper references. This
is all done within the confines of the Django framework. Then, in
tearDown(), I delete all the data and the next unit test re-setups...

My implementation actually uses a base class. In this way, I can have
multiple base unittest classes that setup data in a particular way.

This design not particular efficient -- it's contently creating and
deleting data. But it does satisfy the standard unit test requirement
that each test is independent of other tests. Either order or expected
data.

While I'm sure it has it's down falls, it works very well for my
system.

Frank [tOSU]
http://blog.theOpenSourceU.com/



On May 6, 3:23 am, Chris Withers <[email protected]> wrote:
> Hi All,
>
> Where can I find good examples of django unit tests?
>
> I currently just want to test my models and some helper functions, but
> they will do a .save() on a bunch of model instances.
>
> Any help gratefully recieved!
>
> Chris
>
> --
> 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 
> athttp://groups.google.com/group/django-users?hl=en.

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