Instead of hacking around the settings this way, I would recommend using django's settings override feature: https://docs.djangoproject.com/en/1.4/topics/testing/#overriding-settings

I've had some trouble dealing with it myself in the past, but it might work in this case.