On Sun, Jun 7, 2009 at 7:51 AM, Julien Phalip <jpha...@gmail.com> wrote:

>
> Hi,
>
> In a unit test, I'd like to test the behaviour of a middleware in the
> absence of a setting. To make sure the setting is not present, I try
> to delete it:
>
> def test_middleware(self):
>        if hasattr(settings, 'BLAH'):
>            delattr(settings, 'BLAH')
>        response = self.client.get('/')
>        ...
>
> However, if the setting BLAH exists, the call to delattr returns an
> "Attribute error: BLAH" error.
>
> I'm wondering if that's because the settings are lazily loaded. BTW,
> I'm using Python 2.5.
>
> Do you have a tip on how I could achieve this?
>
> Julien
> >
>
settings don't currently support being deleted, because that's not really
how they're meant to be used (they're meant to be more or less static at run
time).  Perhaps the best solution is to set the value to "None" or some
other value that indicates it's unset.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to