4 messages in com.googlegroups.pylons-discussRe: Modifying config values for unit ...
FromSent OnAttachments
EricHolmberg18 Apr 2008 15:33 
EricHolmberg18 Apr 2008 17:13 
Ian Bicking18 Apr 2008 17:53 
EricHolmberg21 Apr 2008 16:56 
Subject:Re: Modifying config values for unit testing
From:Ian Bicking (ia@colorstudy.com)
Date:04/18/2008 05:53:44 PM
List:com.googlegroups.pylons-discuss

EricHolmberg wrote:

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

Well, a couple ways. You can use multiple configuration files (not just test.ini). You can also pass arguments to loadapp(), like loadapp('test.ini', db='something'), then use %(db)s in your ini file to substitute that value in. Last you can instantiate your application direction from the function in wsgiapp, as the configuration just turns into a simple function call, of the function in wsgiapp.