Wednesday, November 23, 2011

django testing: adapt some vars in settings.py if testing

Hi,

I just started reading about django testing.

Now I have a small question.

Whe running tests I would like to change a few variables in settings.py,
but keep all the rest identical.

Example:
- I might like ot change the media directory
- I might like to use another db engine


How can I achieve this best.

The idea, that I have, but that feels a little clumsy is:
create a test_settings.py file.

test_settings.py will just impoert everything from settings.py
and then override the values it wants to.


Somehow I would prefer if settings.py could contain a few if statements
of the kind.

if testing:
dothis
else:
dothat

and if I could just type
./manage.py test

Is this possible?
How do you handle such setups?

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