On Jun 6, 2006, at 11:10 PM, Don Arbow wrote:

> For unit testing, you don't really need a database. You can always  
> mock the database calls, because you're not testing the data or the  
> database (if postgres is up, the database is working), you're  
> testing your code's behavior to the data. When I first starting  
> using testing methods, I was obsessed with having perfect test  
> data, but quickly realized what I really want is perfect code. I  
> don't really mean perfect, but the code should always be better  
> than the data.

Except that a lot of what I'm doing has interacting pages. If user #1  
makes a change in a page, user #2 should see the output differently  
when they visit another page. (For example, a teacher creates an  
assignment and a student then sees the new assignment when they go to  
the class home page.) So I'd really like to have a database backend  
for testing so that I can actually run the site through its paces  
with some test data to see if everything works the way it should. (In  
other words, make sure that I put stuff where it's supposed to be and  
get it out correctly.)

I've been trying to figure out how I could have two settings files,  
one for the file I use when I'm just playing around with the site  
during development and another for testing that would start clean  
each time I run the tests. I thought about copying the settings.py  
file over and using the --settings= option to manage.py when I do  
runserver, but then I'd have to make changes to both files whenever I  
add a new app or anything like that.

What I'd ideally like to do is create a testsettings.py module that  
would contain all the stuff in settings.py, but would override  
DATABASE_NAME, DATABASE_USER, etc. It seems like, given Python's  
amazing powers of introspection and the existence of functions like  
globals() and locals(), such a thing should be possible. I haven't  
found it, however.

Does anyone know of a way to get all attributes of a module into  
another module while overriding just a few?

Or am I making this too difficult?

Todd

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