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.