[Checkins] SVN: zope.traversing/trunk/ Refactored functional tests to loose dependency on both zope.app.appsetup and zope.app.testing.
Hanno Schlichting
hannosch at hannosch.eu
Tue Dec 15 23:09:01 EST 2009
Log message for revision 106616:
Refactored functional tests to loose dependency on both zope.app.appsetup and zope.app.testing.
Changed:
U zope.traversing/trunk/CHANGES.txt
U zope.traversing/trunk/setup.py
U zope.traversing/trunk/src/zope/traversing/tests/ftesting.zcml
U zope.traversing/trunk/src/zope/traversing/tests/test_vhosting.py
-=-
Modified: zope.traversing/trunk/CHANGES.txt
===================================================================
--- zope.traversing/trunk/CHANGES.txt 2009-12-16 02:15:56 UTC (rev 106615)
+++ zope.traversing/trunk/CHANGES.txt 2009-12-16 04:09:00 UTC (rev 106616)
@@ -5,6 +5,9 @@
3.10.0 (unreleased)
-------------------
+- Refactored functional tests to loose dependency on both zope.app.appsetup
+ and zope.app.testing.
+
- Simplified tests for the browser sub-package by using PlacelessSetup from
zope.component.testing instead of zope.app.testing.
Modified: zope.traversing/trunk/setup.py
===================================================================
--- zope.traversing/trunk/setup.py 2009-12-16 02:15:56 UTC (rev 106615)
+++ zope.traversing/trunk/setup.py 2009-12-16 04:09:00 UTC (rev 106616)
@@ -38,8 +38,8 @@
packages=find_packages('src'),
package_dir = {'': 'src'},
namespace_packages=['zope',],
- extras_require = dict(test=['zope.app.testing',
- 'zope.app.applicationcontrol>=3.5.0',
+ extras_require = dict(test=['zope.app.applicationcontrol>=3.5.0',
+ 'zope.app.publication',
'zope.browserpage',
'zope.browserresource',
'zope.configuration',
@@ -48,9 +48,9 @@
'zope.principalregistry',
'zope.securitypolicy',
'zope.site',
- # The tests expect a spec-compliant TAL
- # interpreter as found in zope.tal 3.5.0
'zope.tal >= 3.5.0',
+ 'zope.testing',
+ 'ZODB3',
]),
install_requires=['setuptools',
'zope.component',
Modified: zope.traversing/trunk/src/zope/traversing/tests/ftesting.zcml
===================================================================
--- zope.traversing/trunk/src/zope/traversing/tests/ftesting.zcml 2009-12-16 02:15:56 UTC (rev 106615)
+++ zope.traversing/trunk/src/zope/traversing/tests/ftesting.zcml 2009-12-16 04:09:00 UTC (rev 106616)
@@ -21,7 +21,6 @@
<include package="zope.site" />
<include package="zope.traversing" />
- <include package="zope.app.appsetup" />
<include package="zope.app.publication" />
<browser:defaultView name="index.html" />
Modified: zope.traversing/trunk/src/zope/traversing/tests/test_vhosting.py
===================================================================
--- zope.traversing/trunk/src/zope/traversing/tests/test_vhosting.py 2009-12-16 02:15:56 UTC (rev 106615)
+++ zope.traversing/trunk/src/zope/traversing/tests/test_vhosting.py 2009-12-16 04:09:00 UTC (rev 106616)
@@ -17,27 +17,32 @@
"""
import os
import unittest
+from StringIO import StringIO
import transaction
from persistent import Persistent
+from ZODB.DB import DB
+from ZODB.DemoStorage import DemoStorage
+from zope.app.publication.browser import BrowserPublication
+
from zope.browserresource.resource import Resource
+from zope.configuration import xmlconfig
from zope.container.contained import Contained
from zope.pagetemplate.pagetemplate import PageTemplate
from zope.pagetemplate.engine import AppPT
+from zope.publisher.browser import BrowserRequest
+from zope.publisher.publish import publish
+from zope.publisher.skinnable import setDefaultSkin
from zope.security.checker import defineChecker, NamesChecker, NoProxy
from zope.security.checker import _checkers, undefineChecker
from zope.site.folder import Folder
+from zope.site.folder import rootFolder
+from zope.testing.cleanup import cleanUp
from zope.traversing.api import traverse
from zope.traversing.testing import browserResource
-from zope.app.testing import functional
-TraversingLayer = functional.ZCMLLayer(
- os.path.join(os.path.split(__file__)[0], 'ftesting.zcml'),
- __name__, 'TraversingLayer', allow_teardown=True)
-
-
class MyObj(Contained):
def __getitem__(self, key):
return traverse(self, '/foo/bar/' + key)
@@ -74,18 +79,38 @@
return ''
-class TestVirtualHosting(functional.BrowserTestCase):
+class TestVirtualHosting(unittest.TestCase):
- layer = TraversingLayer
-
def setUp(self):
- functional.BrowserTestCase.setUp(self)
+ f = os.path.join(os.path.split(__file__)[0], 'ftesting.zcml')
+ xmlconfig.file(f)
+ self.db = DB(DemoStorage("Memory storage unnamed"))
+ self.connection = self.db.open()
+ root = self.connection.root()
+ root_folder = rootFolder()
+ root['Application'] = root_folder
defineChecker(MyObj, NoProxy)
def tearDown(self):
- functional.BrowserTestCase.tearDown(self)
undefineChecker(MyObj)
+ self.connection.close()
+ cleanUp()
+ def makeRequest(self, path=''):
+ env = {"HTTP_HOST": 'localhost',
+ "HTTP_REFERER": 'localhost'}
+ p = path.split('?')
+ if len(p) == 1:
+ env['PATH_INFO'] = p[0]
+
+ request = BrowserRequest(StringIO(''), env)
+ request.setPublication(BrowserPublication(self.db))
+ setDefaultSkin(request)
+ return request
+
+ def publish(self, path):
+ return publish(self.makeRequest(path)).response
+
def test_request_url(self):
self.addPage('/pt', u'<span tal:replace="request/URL"/>')
self.verify('/pt', 'http://localhost/pt/index.html')
@@ -156,7 +181,7 @@
"""addFolders('/a/b/c/d') would traverse and/or create three nested
folders (a, b, c) and return a tuple (c, 'd') where c is a Folder
instance at /a/b/c."""
- folder = self.getRootFolder()
+ folder = self.connection.root()['Application']
if path[0] == '/':
path = path[1:]
path = path.split('/')
@@ -181,7 +206,7 @@
def verify(self, path, content):
result = self.publish(path)
self.assertEquals(result.getStatus(), 200)
- self.assertEquals(result.getBody(), content)
+ self.assertEquals(result.consumeBody(), content)
def verifyRedirect(self, path, location):
result = self.publish(path)
More information about the checkins
mailing list