> I use nose with the --with-pylons setting, then do this in
> load_environment right before `return config` (I have the line
> `testing = true` in my test.ini):
>
> if asbool(config['testing']):
> pylons.config._push_object(config)
> url._push_object(URLGenerator(config['routes.map'], {}))
>
> I haven't needed it, but you could add a line in there for
> app_globals, too:
>
> pylons.app_globals._push_object(config['pylons.app_globals'])
>
> So, I guess that's not really "better", but it works and seems clean
> enough to me.
Yeah, I just spend the morning tracing through the Pylons/Paste code
so that I could fully understand what was going on. I think the
result is that I'll end up doing something very similar to the above.
I had some line of code like this in pylons.test nose plugin begin()
method:
pylons.config.current_conf().update(self.app.config)
But obviously the better approach would be to keep the changes in the
code I control :)
Granted, this doesn't address other similar objects (though
app_globals is addressed above). I think it's unfortunate that Pylons
(with the help of Paste) have chosen to make this so unobvious /
confusing. In my opinion this really discourages people from writing
tests. A developer on my team came to me the other day after porting
from CherryPy to Pylons with the frustration that none of the tests
would run due to pylons.config not containing needed values. She had
tried updating test.ini, development.ini, etc. but the code being
tested would never pull in the configuration files. Having just done
it, I can sympathize that to understand what's going on here takes a
good deal of time. Typical developers getting started with Pylons
aren't going to be able to figure out why it feels like the framework
is completely "broken" for testing. So they're either not going to
test their code -- or they'll go find another framework that works
better. (Unfortunately, and frustratingly, Paste seems to be the
popular choice in the non-Django full-featured-frameworks ... so I can
only assume that they're all going to get mired down in SOP confusion
& misdirection.)
I love Pylons for everything else ... so I'm really hoping that these
problems get the attention of the developers and they address this in
future releases.
Hans
--
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.