Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
355ac9d8
Commit
355ac9d8
authored
Mar 08, 2007
by
Wichert Akkerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set and restore the site for functional tests as well
parent
7789a4ea
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
+16
-0
lib/python/Testing/ZopeTestCase/functional.py
lib/python/Testing/ZopeTestCase/functional.py
+8
-0
lib/python/Testing/ZopeTestCase/zopedoctest/functional.py
lib/python/Testing/ZopeTestCase/zopedoctest/functional.py
+8
-0
No files found.
lib/python/Testing/ZopeTestCase/functional.py
View file @
355ac9d8
...
...
@@ -37,6 +37,7 @@ class Functional(sandbox.Sandboxed):
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
...
...
@@ -47,6 +48,10 @@ class Functional(sandbox.Sandboxed):
# 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
()
...
...
@@ -89,6 +94,9 @@ class Functional(sandbox.Sandboxed):
# Restore security manager
setSecurityManager
(
sm
)
# And we need to restore the site again
setSite
(
old_site
)
return
ResponseWrapper
(
response
,
outstream
,
path
)
...
...
lib/python/Testing/ZopeTestCase/zopedoctest/functional.py
View file @
355ac9d8
...
...
@@ -117,6 +117,7 @@ def http(request_string, handle_errors=True):
"""
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 @@ def http(request_string, handle_errors=True):
# 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 @@ def http(request_string, handle_errors=True):
# 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)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment