On 7 Jun 2006, at 02:42, Todd O'Bryan wrote:

> Does anybody have a best practice (or not-too-annoying practice) for
> testing?
>
> I think I'll use Selenium to test my site, but how should I change to
> a test database, populate the test database, etc.?

This is an area where Django can learn a huge amount from Ruby on  
Rails - they've solved a whole lot of the pain points with regards to  
testing against a database driven app. The two features that would be  
most relevant here are fixtures and a testing environment.

Rails lets you configure a separate database for testing (in fact you  
can have one for development, one for testing and one for deployment)  
- unit tests automatically run against the test DB.

Fixtures are YAML files containing default data which is loaded in to  
your test DB at the start of every test and reset afterwards. I'm not  
overjoyed with YAML for this (it's a little verbose) but it does the  
job and is very friendly to human editing, which is exactly why they  
picked it.

A neat trick for Django would be a command line tool that can dump an  
existing database in to fixture format - YAML or JSON or even  
serialized Python objects. This could serve a dual purpose - at the  
moment migrating Django application data from, for example, postgres  
to mysql requires custom hacking (even though django.db lets you  
interchange databases themselves with ease). Having a database- 
neutral backup/dump format would provide a tool for doing exactly that.

For the moment Django's model tests demonstrate a reasonably way of  
doing this stuff, but they aren't first class citizens of the Django  
environment - you have to do a bit of leg work to get that kind of  
thing set up for your own project. Fixing this would be another  
feather in Django's cap.

Cheers,

Simon

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

Reply via email to