You can use `fixtures` for this purpose! You can have several of them to
have exactly the data you need for a test.

Have a look there:
https://docs.djangoproject.com/en/dev/topics/testing/#django.test.TestCase.fixtures


Cheers,

Thomas

2012/10/4 Daniele Procida <dani...@vurt.org>

> I have started writing my first tests, for a project that has become
> pretty large (several thousand lines of source code).
>
> What needs the most testing - where most of the bugs or incorrect appear
> emerge - are the very complex interactions between objects in the system.
>
> To me, the intuitive way of testing would be this:
>
> * to set up all the objects, in effect creating a complete working database
> * run all the tests on this database
>
> That's pretty much the way I test things without automated tests: is the
> output of the system, running a huge database of objects, correct?
>
> However, I keep reading that I should isolate all my tests. So I have had
> a go at creating tests that do that, but it can mean setting up a dozen
> objects sometimes for a single tiny test, then doing exactly the same thing
> with one small difference for another test.
>
> Often I have to run save() on these objects, because otherwise tests that
> depend on many-to-many and other database relations won't work.
>
> That seems very inefficient, to create a succession of complex and
> nearly-identical test conditions for dozens if not hundreds of tests.
>
> I'd appreciate any advice.
>
> Daniele
>
> --
> 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
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://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 django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to