[Zope-Checkins] SVN: Zope/branches/2.12/src/Products/SiteAccess/tests/test Remove fossilized testing hair, module-scope imports.
Tres Seaver
tseaver at palladion.com
Thu May 20 18:30:42 EDT 2010
Log message for revision 112590:
Remove fossilized testing hair, module-scope imports.
Changed:
U Zope/branches/2.12/src/Products/SiteAccess/tests/testSiteRoot.py
U Zope/branches/2.12/src/Products/SiteAccess/tests/testVirtualHostMonster.py
-=-
Modified: Zope/branches/2.12/src/Products/SiteAccess/tests/testSiteRoot.py
===================================================================
--- Zope/branches/2.12/src/Products/SiteAccess/tests/testSiteRoot.py 2010-05-20 22:30:41 UTC (rev 112589)
+++ Zope/branches/2.12/src/Products/SiteAccess/tests/testSiteRoot.py 2010-05-20 22:30:42 UTC (rev 112590)
@@ -4,47 +4,41 @@
set correctly when a SiteRoot is used.
See http://www.zope.org/Collectors/Zope/2077
-
"""
-
-from Testing.makerequest import makerequest
-
-import Zope2
-Zope2.startup()
-
-import transaction
-
import unittest
class SiteRootRegressions(unittest.TestCase):
def setUp(self):
+ import transaction
+ from Testing.makerequest import makerequest
+ from Testing.ZopeTestCase.ZopeLite import app
transaction.begin()
- self.app = makerequest(Zope2.app())
- try:
- self.app.manage_addFolder('folder')
- self.app.folder.manage_addProduct['SiteAccess'].manage_addSiteRoot(title = 'SiteRoot', base = 'http://test_base', path = '/test_path')
- self.app.REQUEST.set('PARENTS', [self.app])
- self.app.REQUEST.traverse('/folder')
-
- except:
- self.tearDown()
+ self.app = makerequest(app())
+ self.app.manage_addFolder('folder')
+ p_disp = self.app.folder.manage_addProduct['SiteAccess']
+ p_disp.manage_addSiteRoot(title='SiteRoot',
+ base='http://test_base',
+ path='/test_path')
+ self.app.REQUEST.set('PARENTS', [self.app])
+ self.app.REQUEST.traverse('/folder')
def tearDown(self):
+ import transaction
transaction.abort()
self.app._p_jar.close()
-
+
def testRequest(self):
self.assertEqual(self.app.REQUEST['SERVER_URL'], 'http://test_base')
- self.assertEqual(self.app.REQUEST['URL'], 'http://test_base/test_path/index_html')
- self.assertEqual(self.app.REQUEST['ACTUAL_URL'], 'http://test_base/test_path')
- def testAbsoluteUrl(self):
- self.assertEqual(self.app.folder.absolute_url(), 'http://test_base/test_path')
+ self.assertEqual(self.app.REQUEST['URL'],
+ 'http://test_base/test_path/index_html')
+ self.assertEqual(self.app.REQUEST['ACTUAL_URL'],
+ 'http://test_base/test_path')
+ def testAbsoluteUrl(self):
+ self.assertEqual(self.app.folder.absolute_url(),
+ 'http://test_base/test_path')
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(SiteRootRegressions))
return suite
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
Modified: Zope/branches/2.12/src/Products/SiteAccess/tests/testVirtualHostMonster.py
===================================================================
--- Zope/branches/2.12/src/Products/SiteAccess/tests/testVirtualHostMonster.py 2010-05-20 22:30:41 UTC (rev 112589)
+++ Zope/branches/2.12/src/Products/SiteAccess/tests/testVirtualHostMonster.py 2010-05-20 22:30:42 UTC (rev 112590)
@@ -6,38 +6,30 @@
Also see http://zope.org/Collectors/Zope/809
Note: Tests require Zope >= 2.7
-
-$Id$
"""
-
-from Testing.makerequest import makerequest
-
-import Zope2
-Zope2.startup()
-
-import transaction
-
import unittest
-
class VHMRegressions(unittest.TestCase):
def setUp(self):
+ import transaction
+ from Testing.makerequest import makerequest
+ from Testing.ZopeTestCase.ZopeLite import app
transaction.begin()
- self.app = makerequest(Zope2.app())
- try:
- if not hasattr(self.app, 'virtual_hosting'):
- # If ZopeLite was imported, we have no default virtual host monster
- from Products.SiteAccess.VirtualHostMonster import manage_addVirtualHostMonster
- manage_addVirtualHostMonster(self.app, 'virtual_hosting')
- self.app.manage_addFolder('folder')
- self.app.folder.manage_addDTMLMethod('doc', '')
- self.app.REQUEST.set('PARENTS', [self.app])
- self.traverse = self.app.REQUEST.traverse
- except:
- self.tearDown()
+ self.app = makerequest(app())
+ if 'virtual_hosting' not in self.app.objectIds():
+ # If ZopeLite was imported, we have no default virtual
+ # host monster
+ from Products.SiteAccess.VirtualHostMonster \
+ import manage_addVirtualHostMonster
+ manage_addVirtualHostMonster(self.app, 'virtual_hosting')
+ self.app.manage_addFolder('folder')
+ self.app.folder.manage_addDTMLMethod('doc', '')
+ self.app.REQUEST.set('PARENTS', [self.app])
+ self.traverse = self.app.REQUEST.traverse
def tearDown(self):
+ import transaction
transaction.abort()
self.app._p_jar.close()
@@ -61,15 +53,27 @@
def test_actual_url(self):
self.app.folder.manage_addDTMLMethod('index_html', '')
- ob = self.traverse('/VirtualHostBase/http/www.mysite.com:80/folder/VirtualHostRoot/doc/')
- self.assertEqual(self.app.REQUEST['ACTUAL_URL'], 'http://www.mysite.com/doc/')
- ob = self.traverse('/VirtualHostBase/http/www.mysite.com:80/folder/VirtualHostRoot/doc')
- self.assertEqual(self.app.REQUEST['ACTUAL_URL'], 'http://www.mysite.com/doc')
- ob = self.traverse('/VirtualHostBase/http/www.mysite.com:80/folder/VirtualHostRoot/')
- self.assertEqual(self.app.REQUEST['ACTUAL_URL'], 'http://www.mysite.com/')
- ob = self.traverse('/VirtualHostBase/http/www.mysite.com:80/folder/VirtualHostRoot')
- self.assertEqual(self.app.REQUEST['ACTUAL_URL'], 'http://www.mysite.com/')
+ ob = self.traverse('/VirtualHostBase/http/www.mysite.com:80'
+ '/folder/VirtualHostRoot/doc/')
+ self.assertEqual(self.app.REQUEST['ACTUAL_URL'],
+ 'http://www.mysite.com/doc/')
+
+ ob = self.traverse('/VirtualHostBase/http/www.mysite.com:80'
+ '/folder/VirtualHostRoot/doc')
+ self.assertEqual(self.app.REQUEST['ACTUAL_URL'],
+ 'http://www.mysite.com/doc')
+
+ ob = self.traverse('/VirtualHostBase/http/www.mysite.com:80'
+ '/folder/VirtualHostRoot/')
+ self.assertEqual(self.app.REQUEST['ACTUAL_URL'],
+ 'http://www.mysite.com/')
+
+ ob = self.traverse('/VirtualHostBase/http/www.mysite.com:80'
+ '/folder/VirtualHostRoot')
+ self.assertEqual(self.app.REQUEST['ACTUAL_URL'],
+ 'http://www.mysite.com/')
+
def gen_cases():
for vbase, ubase in (
('', 'http://foo'),
@@ -174,7 +178,3 @@
suite.addTest(unittest.makeSuite(VHMRegressions))
suite.addTest(unittest.makeSuite(VHMAddingTests))
return suite
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
-
More information about the Zope-Checkins
mailing list