> Let me start with an example test:
> 
> def test_with_awesome_setting(self):
>    _orig = getattr(settings, 'AWESOME', None)
>    settings.AWESOME = True
> 
>    # do my test
>    ...
> 
>    settings.AWESOME = _orig
> 

Pedant: there's a small bug above which has bitten me before doing a similar 
thing - settings.AWESOME  ends up set to None after the test has run if it 
didn't exist before. 

> Anyways, I'd love to hear how others have dealt with this and any
> other possible solutions.

I've used Michael Foord's Mock library to patch a setting for the duration of a 
test case. Chris Withers' testfixtures library also has some sugar to provide a 
context manager approach, though I haven't used that in a little while.

Cheers,
Dan

--
Dan Fairs | dan.fa...@gmail.com | www.fezconsulting.com


-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-develop...@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to