Well, yes. As you have already discovered, publish() creates it's own REQUEST (also see ZPublisher.Test). All you have after a call to publish() is the response object. Note that you *can* check ZODB- based variables after publish(). However the REQUEST is not stored in the ZODB...

Which begs the question why you need publish() in the first place. It is only useful if you want to test the Publisher, i.e. the status code, or some returned headers and cookies. Everything else can be tested directly. How to put a session object into self.app.REQUEST is demonstrated in the testShoppingCart.py example test.


On 21. Nov 2005, at 03:46, Paul Winkler wrote:

Yes, everything is fine unless you attempt to access the session
from the test code. So I can't see any way to e.g. assert that after
publishing a page, a certain variable is set in the session.
For example, I wish I could rewrite your test like so:

    def testUseSessions(self):
        response = self.publish(self.folder_path+'/use_session')
        self.assertEqual(response.getStatus(), 200)
        self.assertEqual(self.app.REQUEST.SESSION.get('foo', 'xxx'),

Anything that happens, happens.  --Douglas Adams

Zope maillist  -  Zope@zope.org
**   No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to