[Zope-Checkins] SVN: Zope/trunk/lib/python/Testing/ZopeTestCase/
Set and restore the site for functional tests as well.
Forward port from 2.10 branch
Wichert Akkerman
wichert at wiggy.net
Wed Mar 7 20:23:56 EST 2007
Log message for revision 73048:
Set and restore the site for functional tests as well. Forward port from 2.10 branch
Changed:
U Zope/trunk/lib/python/Testing/ZopeTestCase/functional.py
U Zope/trunk/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py
-=-
Modified: Zope/trunk/lib/python/Testing/ZopeTestCase/functional.py
===================================================================
--- Zope/trunk/lib/python/Testing/ZopeTestCase/functional.py 2007-03-08 01:23:02 UTC (rev 73047)
+++ Zope/trunk/lib/python/Testing/ZopeTestCase/functional.py 2007-03-08 01:23:55 UTC (rev 73048)
@@ -39,6 +39,7 @@
request_method='GET', stdin=None, handle_errors=True):
'''Publishes the object at 'path' returning a response object.'''
+ from zope.app.component.hooks import setSite, getSite
from StringIO import StringIO
from ZPublisher.Response import Response
from ZPublisher.Test import publish_module
@@ -49,6 +50,10 @@
# Save current security manager
sm = getSecurityManager()
+ # And we need to store the old site
+ old_site = getSite()
+ setSite(None)
+
# Commit the sandbox for good measure
transaction.commit()
@@ -91,6 +96,9 @@
# Restore security manager
setSecurityManager(sm)
+ # And we need to restore the site again
+ setSite(old_site)
+
return ResponseWrapper(response, outstream, path)
Modified: Zope/trunk/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py
===================================================================
--- Zope/trunk/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py 2007-03-08 01:23:02 UTC (rev 73047)
+++ Zope/trunk/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py 2007-03-08 01:23:55 UTC (rev 73048)
@@ -117,6 +117,7 @@
"""
import urllib
import rfc822
+ from zope.app.component.hooks import setSite, getSite
from cStringIO import StringIO
from ZPublisher.Response import Response
from ZPublisher.Test import publish_module
@@ -126,6 +127,10 @@
# Save current Security Manager
old_sm = getSecurityManager()
+ # And we need to store the old site
+ old_site = getSite()
+ setSite(None)
+
# Commit work done by previous python code.
transaction.commit()
@@ -193,7 +198,10 @@
# by calling the publish method above
setSecurityManager(old_sm)
+ # And we need to restore the site again
+ setSite(old_site)
# Sync connection
+
sync()
return DocResponseWrapper(response, outstream, path, header_output)
More information about the Zope-Checkins
mailing list