I have some controllers that use configuration values to control their
behavior.  I want to test this behavior, so I would like to set the
configuration item to a known value and run a test.  What's the best
way to do this (or should I be using the configuration values
differently)?

Example code (here I have cached the values in the constructor, I
could also load them for each request, although I would like to avoid
that if possible).

In controller:

from pylons import config

def __init__(self):
  self.bDoNothing = asbool(config['do_nothing'])

def do_something(self):
  if self.bDoNothing:
    return 'No'
  else:
    return self.doSomething()


Unit test:

 def test_do_somethingNo(self):
    config['do_nothing'] = 'false'
    response = self.app.get('/do_something')
    # ...


Thanks,

Eric
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to