Hi, thank you for all that answers, this was really helpful!<br><br><div class="gmail_quote">On Mon, Jun 22, 2009 at 12:18, Hanno Schlichting <span dir="ltr">&lt;hanno@hannosch.eu&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div class="im">On Tue, Jun 16, 2009 at 10:35 PM, Patrick Gerken&lt;<a href="mailto:do3ccqrv@googlemail.com">do3ccqrv@googlemail.com</a>&gt; wrote:<br>
&gt; A testcase in my code fails, and after a lot of digging, I am finding that<br>
&gt; the reason are wrong results from the catalog. The catalog returns bad<br>
&gt; results because he caches the results in the request.<br>
&gt; My test consists of a number of steps, for multiple times I do a<br>
&gt; getMultiAdapter, always with fresh TestRequests. Still it seems, that the<br>
&gt; catalog always use some other, rotten REQUEST.<br>
<br>
</div>Looking at this again, you are missing an important point about the<br>
test framework you use.<br>
<br>
In all of ZopeTestCase (CMFTestCase, PloneTestCase) you get a<br>
convenience request object set up for you, reachable as app.REQUEST.<br>
This mirrors the way you usually get access to the request object in<br>
Zope2 via Acquisition down to the application root. It&#39;s meant to<br>
emulate a very minimal request object.<br>
<br>
Now in normal operation, you would get one request object per HTTP<br>
request. This also works in the functional variants of the test case<br>
classes.<br>
<br>
In the non-functional test classes you only ever get one request<br>
object set up, as there&#39;s no object publishing or HTTP request<br>
handling being done. If you or any code you call changes any settings<br>
on that request object and you want to test things dependent on this<br>
you have two options:  Either create a fresh request yourself (using<br>
Testing.makerequest) in your tests or use a functional test case<br>
instead.</blockquote><div><br>I did excactly that. Since it was a caching issue in code out of my reach, I had problems with.<br>Sadly, creating a new request and saving it on self.app.REQUEST was not enough.<br><br>The code in question acquires the method that caches something on the REQUEST from a getSite() call.<br>

It seems like getSite() returns a copy of the site, and that has its own copy of the request too.<br><br>&gt;&gt;&gt; self.app.REQUEST == getSite().REQUEST<br>True<br><br>&gt;&gt;&gt; self.app = makerequest(self.app)<br>
&gt;&gt;&gt; self.app.REQUEST == getSite().REQUEST<br>
False<br><br>The copy getSite() returns is deleted in an EndRequest Event handler...<br><br>I did not use zc.testbrowser for testing, because I did test XMLRPC Methods, and it seemed easier to just use getMultiAdapter and test the view directly.<br>

<br>I solved my issues but it is a bit inconvenient nowadays...<br><br>Best regards and thank you!<br><br>Patrick<br></div></div><br>