Hi -
On several recent projects I've needed unit tests that involved reading
values and making assertions about the current pylons session. I would
really like to be able to read and write the session without using TestApp
-- so that my code being tested and my tests are in the same context (I'm
testing services functions).
Do other people do this? If so, is there a good way to have the test code
and the application share the same session object? The fact that these are
stacked object proxies makes this problem very perplexing.
When I just try to reference the session ("from pylons import session") in
my tested code, I get this error:
"TypeError: No object (name: session) has been registered for this thread"
My base test class __init__ method has some boilerplate pylons code:
if pylons.test.pylonsapp:
wsgiapp = pylons.test.pylonsapp
else:
wsgiapp = loadapp('config:%s' % config['__file__'])
... I would have thought that this would setup my beaker session for the
applicaiton. (?)
The only way I can get the tested code to work correctly is to use a wsgi
service proxy service class and actually manually set up the pylons
application (adding in the Beaker middleware).
I feel like I must be missing something basic. What I'm trying to do is
just have the current "pylons.session" initialized so that I can make use
of it. I suppose I can dig in and figure out where that value is set by
pylons and just try to do that myself. I figured I would ask first to see
if someone else can explain to me how they do this.
Thanks in advance!
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
-~----------~----~----~----~------~----~------~--~---