As the person that seems to be most knowledgable about django testing
(your Django 1.1 Testing book is fantastic - I highly recommend it!),
can you confirm that something like this is the best way to go? It
seems strange to me that there is no more standard way of dumping the
database from inside a test so that the state can be replicated for
use in a runserver environment.
Margie
On Jun 1, 2:01 pm, Kirill Spitsin <t...@0x746e.org.ua> wrote:
> On Wed, Jun 01, 2011 at 11:59:28AM -0700, Margie Roginski wrote:
> > That's a good pointer, thanks. However I'm still confused about how I
> > can actually dump out the data from my test run? For example, say I
> > have a particular test and I want to dump the data at some certain
> > point. I can put in pdb.set_trace() in the code to stop at the
> > appropriate point, but what do I call from that point to create the
> > mydata.json file that then gets loaded with the command
>
> > django-admin.py testserver mydata.json
> >>> from django.core.serializers import serialize
> >>> queryset1 = Model1.objects.filter(...)
> >>> queryset2 = Model2.objects.filter(...)
> >>> fixture = serialize('json', list(queryset1) + list(queryset2))
> >>> f = open('mydate.json', 'w')
> >>> f.write(fixture)
> >>> f.close()
>
> --
> Kirill Spitsin
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment