On Tue, Jun 16, 2009 at 10:35 PM, Patrick Gerken<do3cc...@googlemail.com> wrote:
> A testcase in my code fails, and after a lot of digging, I am finding that
> the reason are wrong results from the catalog. The catalog returns bad
> results because he caches the results in the request.
> My test consists of a number of steps, for multiple times I do a
> getMultiAdapter, always with fresh TestRequests. Still it seems, that the
> catalog always use some other, rotten REQUEST.

Looking at this again, you are missing an important point about the
test framework you use.

In all of ZopeTestCase (CMFTestCase, PloneTestCase) you get a
convenience request object set up for you, reachable as app.REQUEST.
This mirrors the way you usually get access to the request object in
Zope2 via Acquisition down to the application root. It's meant to
emulate a very minimal request object.

Now in normal operation, you would get one request object per HTTP
request. This also works in the functional variants of the test case

In the non-functional test classes you only ever get one request
object set up, as there's no object publishing or HTTP request
handling being done. If you or any code you call changes any settings
on that request object and you want to test things dependent on this
you have two options:  Either create a fresh request yourself (using
Testing.makerequest) in your tests or use a functional test case

Especially in Plone where quite a bit of information is cached on the
request object, you can run into this situation.

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

Reply via email to