[Zope-Checkins] SVN: Zope/trunk/ Removed the dependency on `zope.app.testing` in favor of providing a more minimal placeless setup as part of ZopeTestCase for our own tests.

Hanno Schlichting hannosch at hannosch.eu
Sun Apr 26 12:33:20 EDT 2009


Log message for revision 99527:
  Removed the dependency on `zope.app.testing` in favor of providing a more minimal placeless setup as part of ZopeTestCase for our own tests.
  

Changed:
  U   Zope/trunk/alltests.cfg
  U   Zope/trunk/doc/CHANGES.rst
  U   Zope/trunk/setup.py
  U   Zope/trunk/src/OFS/tests/testObjectManager.py
  U   Zope/trunk/src/OFS/tests/testTraverse.py
  U   Zope/trunk/src/Products/Five/browser/tests/aqlegacy_ftest.txt
  U   Zope/trunk/src/Products/Five/browser/tests/pages.txt
  U   Zope/trunk/src/Products/Five/browser/tests/pages_ftest.txt
  U   Zope/trunk/src/Products/Five/browser/tests/resource.txt
  U   Zope/trunk/src/Products/Five/browser/tests/resource_ftest.txt
  U   Zope/trunk/src/Products/Five/browser/tests/skin.txt
  U   Zope/trunk/src/Products/Five/browser/tests/test_absoluteurl.py
  U   Zope/trunk/src/Products/Five/browser/tests/test_defaultview.py
  U   Zope/trunk/src/Products/Five/browser/tests/test_i18n.py
  U   Zope/trunk/src/Products/Five/browser/tests/test_menu.py
  U   Zope/trunk/src/Products/Five/browser/tests/test_pages.py
  U   Zope/trunk/src/Products/Five/browser/tests/test_traversable.py
  U   Zope/trunk/src/Products/Five/browser/tests/test_zope3security.py
  U   Zope/trunk/src/Products/Five/form/tests/forms.txt
  U   Zope/trunk/src/Products/Five/form/tests/test_forms.py
  U   Zope/trunk/src/Products/Five/formlib/tests/formlib.txt
  U   Zope/trunk/src/Products/Five/skin/tests/test_standardmacros.py
  U   Zope/trunk/src/Products/Five/tests/boilerplate.py
  U   Zope/trunk/src/Products/Five/tests/test_registerclass.py
  U   Zope/trunk/src/Products/Five/tests/test_registerpackage.py
  U   Zope/trunk/src/Products/Five/tests/test_security.py
  U   Zope/trunk/src/Products/Five/tests/test_size.py
  U   Zope/trunk/src/Products/Five/utilities/browser/tests/test_marker.py
  U   Zope/trunk/src/Products/Five/viewlet/README.txt
  U   Zope/trunk/src/Products/Five/viewlet/tests.py
  U   Zope/trunk/src/Testing/ZopeTestCase/placeless.py
  U   Zope/trunk/src/Zope2/App/tests/testExceptionHook.py

-=-
Modified: Zope/trunk/alltests.cfg
===================================================================
--- Zope/trunk/alltests.cfg	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/alltests.cfg	2009-04-26 16:33:20 UTC (rev 99527)
@@ -65,6 +65,7 @@
     zope.app.principalannotation
     zope.app.schema
     zope.app.securitypolicy
+    zope.app.testing
     zope.app.zcmlfiles
     zope.app.zptpage
     python-gettext

Modified: Zope/trunk/doc/CHANGES.rst
===================================================================
--- Zope/trunk/doc/CHANGES.rst	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/doc/CHANGES.rst	2009-04-26 16:33:20 UTC (rev 99527)
@@ -8,6 +8,12 @@
 Trunk (unreleased)
 ------------------
 
+Restructuring
++++++++++++++
+
+- Removed the dependency on `zope.app.testing` in favor of providing a more
+  minimal placeless setup as part of ZopeTestCase for our own tests.
+
 Bugs Fixed
 ++++++++++
 
@@ -29,17 +35,6 @@
 The generated tarball for the 2.12.0a2 source release was incomplete, due to
 a setuptools and Subversion 1.6 incompatibility.
 
-Known issues
-++++++++++++
-
-- Running Zope on Windows is not yet supported in this alpha release.
-  More specifically the generated startup scripts need to be adjusted,
-  while the code itself should work fine.
-
-- ZODB 3.9.0a12 does not work on Windows with Python 2.6 yet.
-
-- easy_install support not fully functional yet.
-
 Restructuring
 +++++++++++++
 

Modified: Zope/trunk/setup.py
===================================================================
--- Zope/trunk/setup.py	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/setup.py	2009-04-26 16:33:20 UTC (rev 99527)
@@ -143,6 +143,7 @@
       'zope.testing',
       'zope.traversing',
       'zope.viewlet',
+      'zope.app.appsetup',
       'zope.app.component',
       'zope.app.container',
       'zope.app.form',
@@ -151,7 +152,6 @@
       'zope.app.publication',
       'zope.app.publisher',
       'zope.app.schema',
-      'zope.app.testing',
     ],
 
     include_package_data=True,

Modified: Zope/trunk/src/OFS/tests/testObjectManager.py
===================================================================
--- Zope/trunk/src/OFS/tests/testObjectManager.py	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/src/OFS/tests/testObjectManager.py	2009-04-26 16:33:20 UTC (rev 99527)
@@ -1,6 +1,6 @@
 import unittest
 
-from zope.app.testing.placelesssetup import PlacelessSetup
+from zope.component.testing import PlacelessSetup
 
 from AccessControl.Owned import EmergencyUserCannotOwn
 from AccessControl.SecurityManagement import newSecurityManager

Modified: Zope/trunk/src/OFS/tests/testTraverse.py
===================================================================
--- Zope/trunk/src/OFS/tests/testTraverse.py	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/src/OFS/tests/testTraverse.py	2009-04-26 16:33:20 UTC (rev 99527)
@@ -544,7 +544,7 @@
 
     Clean up:
 
-      >>> from zope.app.testing.placelesssetup import tearDown
+      >>> from zope.component.testing import tearDown
       >>> tearDown()
 
     Verify that after cleanup, there's no cruft left from five:traversable::
@@ -652,7 +652,7 @@
 
     Clean up:
 
-      >>> from zope.app.testing.placelesssetup import tearDown
+      >>> from zope.component.testing import tearDown
       >>> tearDown()
     """
 

Modified: Zope/trunk/src/Products/Five/browser/tests/aqlegacy_ftest.txt
===================================================================
--- Zope/trunk/src/Products/Five/browser/tests/aqlegacy_ftest.txt	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/src/Products/Five/browser/tests/aqlegacy_ftest.txt	2009-04-26 16:33:20 UTC (rev 99527)
@@ -200,5 +200,5 @@
 Clean up
 --------
 
-  >>> from zope.app.testing.placelesssetup import tearDown
+  >>> from zope.component.testing import tearDown
   >>> tearDown()

Modified: Zope/trunk/src/Products/Five/browser/tests/pages.txt
===================================================================
--- Zope/trunk/src/Products/Five/browser/tests/pages.txt	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/src/Products/Five/browser/tests/pages.txt	2009-04-26 16:33:20 UTC (rev 99527)
@@ -330,5 +330,5 @@
 Clean up
 --------
 
-  >>> from zope.app.testing.placelesssetup import tearDown
+  >>> from zope.component.testing import tearDown
   >>> tearDown()

Modified: Zope/trunk/src/Products/Five/browser/tests/pages_ftest.txt
===================================================================
--- Zope/trunk/src/Products/Five/browser/tests/pages_ftest.txt	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/src/Products/Five/browser/tests/pages_ftest.txt	2009-04-26 16:33:20 UTC (rev 99527)
@@ -156,5 +156,5 @@
 Clean up
 --------
 
-  >>> from zope.app.testing.placelesssetup import tearDown
+  >>> from zope.component.testing import tearDown
   >>> tearDown()

Modified: Zope/trunk/src/Products/Five/browser/tests/resource.txt
===================================================================
--- Zope/trunk/src/Products/Five/browser/tests/resource.txt	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/src/Products/Five/browser/tests/resource.txt	2009-04-26 16:33:20 UTC (rev 99527)
@@ -112,5 +112,5 @@
 Clean up
 --------
 
-  >>> from zope.app.testing.placelesssetup import tearDown
+  >>> from zope.component.testing import tearDown
   >>> tearDown()

Modified: Zope/trunk/src/Products/Five/browser/tests/resource_ftest.txt
===================================================================
--- Zope/trunk/src/Products/Five/browser/tests/resource_ftest.txt	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/src/Products/Five/browser/tests/resource_ftest.txt	2009-04-26 16:33:20 UTC (rev 99527)
@@ -130,5 +130,5 @@
 Clean up
 --------
 
-  >>> from zope.app.testing.placelesssetup import tearDown
+  >>> from zope.component.testing import tearDown
   >>> tearDown()

Modified: Zope/trunk/src/Products/Five/browser/tests/skin.txt
===================================================================
--- Zope/trunk/src/Products/Five/browser/tests/skin.txt	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/src/Products/Five/browser/tests/skin.txt	2009-04-26 16:33:20 UTC (rev 99527)
@@ -50,5 +50,5 @@
 Clean up
 --------
 
-  >>> from zope.app.testing.placelesssetup import tearDown
+  >>> from zope.component.testing import tearDown
   >>> tearDown()

Modified: Zope/trunk/src/Products/Five/browser/tests/test_absoluteurl.py
===================================================================
--- Zope/trunk/src/Products/Five/browser/tests/test_absoluteurl.py	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/src/Products/Five/browser/tests/test_absoluteurl.py	2009-04-26 16:33:20 UTC (rev 99527)
@@ -81,7 +81,7 @@
 
     Clean up:
 
-      >>> from zope.app.testing.placelesssetup import tearDown
+      >>> from zope.component.testing import tearDown
       >>> tearDown()
     """
 

Modified: Zope/trunk/src/Products/Five/browser/tests/test_defaultview.py
===================================================================
--- Zope/trunk/src/Products/Five/browser/tests/test_defaultview.py	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/src/Products/Five/browser/tests/test_defaultview.py	2009-04-26 16:33:20 UTC (rev 99527)
@@ -81,7 +81,7 @@
 
     Clean up:
 
-      >>> from zope.app.testing.placelesssetup import tearDown
+      >>> from zope.component.testing import tearDown
       >>> tearDown()
     """
 

Modified: Zope/trunk/src/Products/Five/browser/tests/test_i18n.py
===================================================================
--- Zope/trunk/src/Products/Five/browser/tests/test_i18n.py	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/src/Products/Five/browser/tests/test_i18n.py	2009-04-26 16:33:20 UTC (rev 99527)
@@ -80,7 +80,7 @@
 
     Clean up:
 
-      >>> from zope.app.testing.placelesssetup import tearDown
+      >>> from zope.component.testing import tearDown
       >>> tearDown()
     """
 

Modified: Zope/trunk/src/Products/Five/browser/tests/test_menu.py
===================================================================
--- Zope/trunk/src/Products/Five/browser/tests/test_menu.py	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/src/Products/Five/browser/tests/test_menu.py	2009-04-26 16:33:20 UTC (rev 99527)
@@ -166,7 +166,7 @@
 
     Clean up:
 
-      >>> from zope.app.testing.placelesssetup import tearDown
+      >>> from zope.component.testing import tearDown
       >>> tearDown()
     """
 

Modified: Zope/trunk/src/Products/Five/browser/tests/test_pages.py
===================================================================
--- Zope/trunk/src/Products/Five/browser/tests/test_pages.py	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/src/Products/Five/browser/tests/test_pages.py	2009-04-26 16:33:20 UTC (rev 99527)
@@ -61,7 +61,7 @@
 
     Clean up:
 
-    >>> from zope.app.testing.placelesssetup import tearDown
+    >>> from zope.component.testing import tearDown
     >>> tearDown()
     """
 

Modified: Zope/trunk/src/Products/Five/browser/tests/test_traversable.py
===================================================================
--- Zope/trunk/src/Products/Five/browser/tests/test_traversable.py	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/src/Products/Five/browser/tests/test_traversable.py	2009-04-26 16:33:20 UTC (rev 99527)
@@ -161,7 +161,7 @@
 
     Clean up:
 
-      >>> from zope.app.testing.placelesssetup import tearDown
+      >>> from zope.component.testing import tearDown
       >>> tearDown()
 
     Verify that after cleanup, there's no cruft left from five:traversable::
@@ -278,7 +278,7 @@
       
     Clean up:
 
-      >>> from zope.app.testing.placelesssetup import tearDown
+      >>> from zope.component.testing import tearDown
       >>> tearDown()
     """
 

Modified: Zope/trunk/src/Products/Five/browser/tests/test_zope3security.py
===================================================================
--- Zope/trunk/src/Products/Five/browser/tests/test_zope3security.py	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/src/Products/Five/browser/tests/test_zope3security.py	2009-04-26 16:33:20 UTC (rev 99527)
@@ -48,7 +48,7 @@
 
     Clean up:
 
-      >>> from zope.app.testing.placelesssetup import tearDown
+      >>> from zope.component.testing import tearDown
       >>> tearDown()
 
     """

Modified: Zope/trunk/src/Products/Five/form/tests/forms.txt
===================================================================
--- Zope/trunk/src/Products/Five/form/tests/forms.txt	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/src/Products/Five/form/tests/forms.txt	2009-04-26 16:33:20 UTC (rev 99527)
@@ -568,5 +568,5 @@
 
 Finally, we need to clean up:
 
-  >>> from zope.app.testing.placelesssetup import tearDown
+  >>> from zope.component.testing import tearDown
   >>> tearDown()

Modified: Zope/trunk/src/Products/Five/form/tests/test_forms.py
===================================================================
--- Zope/trunk/src/Products/Five/form/tests/test_forms.py	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/src/Products/Five/form/tests/test_forms.py	2009-04-26 16:33:20 UTC (rev 99527)
@@ -53,7 +53,7 @@
 
     Clean up:
 
-      >>> from zope.app.testing.placelesssetup import tearDown
+      >>> from zope.component.testing import tearDown
       >>> tearDown()
     """
 

Modified: Zope/trunk/src/Products/Five/formlib/tests/formlib.txt
===================================================================
--- Zope/trunk/src/Products/Five/formlib/tests/formlib.txt	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/src/Products/Five/formlib/tests/formlib.txt	2009-04-26 16:33:20 UTC (rev 99527)
@@ -82,5 +82,5 @@
 
 Finally, we need to clean up:
 
-  >>> from zope.app.testing.placelesssetup import tearDown
+  >>> from zope.component.testing import tearDown
   >>> tearDown()

Modified: Zope/trunk/src/Products/Five/skin/tests/test_standardmacros.py
===================================================================
--- Zope/trunk/src/Products/Five/skin/tests/test_standardmacros.py	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/src/Products/Five/skin/tests/test_standardmacros.py	2009-04-26 16:33:20 UTC (rev 99527)
@@ -69,7 +69,7 @@
 
     Clean up:
 
-      >>> from zope.app.testing.placelesssetup import tearDown
+      >>> from zope.component.testing import tearDown
       >>> tearDown()
     """
 

Modified: Zope/trunk/src/Products/Five/tests/boilerplate.py
===================================================================
--- Zope/trunk/src/Products/Five/tests/boilerplate.py	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/src/Products/Five/tests/boilerplate.py	2009-04-26 16:33:20 UTC (rev 99527)
@@ -18,7 +18,7 @@
 
 def test_boilerplate():
     """
-      >>> from zope.app.testing.placelesssetup import setUp, tearDown
+      >>> from zope.component.testing import setUp, tearDown
       >>> setUp()
 
       >>> import Products.Five.tests

Modified: Zope/trunk/src/Products/Five/tests/test_registerclass.py
===================================================================
--- Zope/trunk/src/Products/Five/tests/test_registerclass.py	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/src/Products/Five/tests/test_registerclass.py	2009-04-26 16:33:20 UTC (rev 99527)
@@ -20,7 +20,7 @@
     """
     Testing registerClass
 
-      >>> from zope.app.testing.placelesssetup import setUp, tearDown
+      >>> from zope.component.testing import setUp, tearDown
       >>> setUp()
       >>> import Products
       >>> import Products.Five

Modified: Zope/trunk/src/Products/Five/tests/test_registerpackage.py
===================================================================
--- Zope/trunk/src/Products/Five/tests/test_registerpackage.py	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/src/Products/Five/tests/test_registerpackage.py	2009-04-26 16:33:20 UTC (rev 99527)
@@ -26,7 +26,7 @@
     """
     Testing registerPackage
 
-      >>> from zope.app.testing.placelesssetup import setUp, tearDown
+      >>> from zope.component.testing import setUp, tearDown
       >>> setUp()
       >>> import Products
       >>> import Products.Five

Modified: Zope/trunk/src/Products/Five/tests/test_security.py
===================================================================
--- Zope/trunk/src/Products/Five/tests/test_security.py	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/src/Products/Five/tests/test_security.py	2009-04-26 16:33:20 UTC (rev 99527)
@@ -67,7 +67,7 @@
     Zope 2 can be replaced by ZCML statements without any loss of
     information.
 
-      >>> from zope.app.testing.placelesssetup import setUp, tearDown
+      >>> from zope.component.testing import setUp, tearDown
       >>> setUp()
 
     We start out with two classes, ``Dummy1`` and ``Dummy2``.  They
@@ -162,7 +162,7 @@
     """This test demonstrates that allowed_interface security declarations work
     as expected.
 
-      >>> from zope.app.testing.placelesssetup import setUp, tearDown
+      >>> from zope.component.testing import setUp, tearDown
       >>> setUp()
 
     Before we can make security declarations through ZCML, we need to
@@ -236,7 +236,7 @@
     Zope 2, but we want to be able to re-use pure Zope 3 packages that use
     them without error.
 
-      >>> from zope.app.testing.placelesssetup import setUp, tearDown
+      >>> from zope.component.testing import setUp, tearDown
       >>> setUp()
 
     Before we can make security declarations through ZCML, we need to
@@ -284,7 +284,7 @@
     """
     Test checkPermission
 
-      >>> from zope.app.testing.placelesssetup import setUp, tearDown
+      >>> from zope.component.testing import setUp, tearDown
       >>> setUp()
 
     Zope 3 has a function zope.security.checkPermission which provides
@@ -379,7 +379,7 @@
     to create a permission that does not already exist, it is created on 
     startup, with roles defaulting to Manager.
 
-      >>> from zope.app.testing.placelesssetup import setUp, tearDown
+      >>> from Testing.ZopeTestCase.placeless import setUp, tearDown
       >>> setUp()
 
     First, we need to configure the relevant parts of Five.

Modified: Zope/trunk/src/Products/Five/tests/test_size.py
===================================================================
--- Zope/trunk/src/Products/Five/tests/test_size.py	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/src/Products/Five/tests/test_size.py	2009-04-26 16:33:20 UTC (rev 99527)
@@ -51,7 +51,7 @@
 
     Set up:
 
-      >>> from zope.app.testing.placelesssetup import setUp, tearDown
+      >>> from zope.component.testing import setUp, tearDown
       >>> setUp()
 
       >>> configure_zcml = '''

Modified: Zope/trunk/src/Products/Five/utilities/browser/tests/test_marker.py
===================================================================
--- Zope/trunk/src/Products/Five/utilities/browser/tests/test_marker.py	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/src/Products/Five/utilities/browser/tests/test_marker.py	2009-04-26 16:33:20 UTC (rev 99527)
@@ -20,7 +20,7 @@
     """
     Set everything up:
 
-      >>> from zope.app.testing.placelesssetup import setUp, tearDown
+      >>> from zope.component.testing import setUp, tearDown
       >>> setUp()
       >>> import Products.Five
       >>> import Products.Five.utilities

Modified: Zope/trunk/src/Products/Five/viewlet/README.txt
===================================================================
--- Zope/trunk/src/Products/Five/viewlet/README.txt	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/src/Products/Five/viewlet/README.txt	2009-04-26 16:33:20 UTC (rev 99527)
@@ -361,6 +361,18 @@
 to demonstrate the helper functions here, since those demonstrations will
 fully demonstrate the functionality of the base classes as well.
 
+  >>> from zope.interface import Interface
+  >>> from zope.component import getGlobalSiteManager
+  >>> from zope.publisher.interfaces.browser import IDefaultBrowserLayer
+  >>> def registerResource(name, factory):
+  ...     gsm = getGlobalSiteManager()
+  ...     gsm.registerAdapter(
+  ...         factory,
+  ...         required=(IDefaultBrowserLayer, ),
+  ...         provided=Interface,
+  ...         name=name,
+  ...     )
+
 The viewlet will look up the resource it was given and tries to produce the
 absolute URL for it:
 
@@ -371,8 +383,7 @@
   ...     def __call__(self):
   ...         return '/@@/resource.js'
 
-  >>> from zope.app.testing import ztapi
-  >>> ztapi.browserResource('resource.js', JSResource)
+  >>> registerResource('resource.js', JSResource)
   >>> JSViewlet = viewlet.JavaScriptViewlet('resource.js')
   >>> print JSViewlet(content, request, view, manager).render().strip()
   <script type="text/javascript" src="/@@/resource.js">
@@ -387,7 +398,7 @@
   ...     def __call__(self):
   ...         return '/@@/resource.css'
 
-  >>> ztapi.browserResource('resource.css', CSSResource)
+  >>> registerResource('resource.css', CSSResource)
 
   >>> CSSViewlet = viewlet.CSSViewlet('resource.css')
   >>> print CSSViewlet(content, request, view, manager).render().strip()

Modified: Zope/trunk/src/Products/Five/viewlet/tests.py
===================================================================
--- Zope/trunk/src/Products/Five/viewlet/tests.py	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/src/Products/Five/viewlet/tests.py	2009-04-26 16:33:20 UTC (rev 99527)
@@ -19,7 +19,6 @@
 
 import unittest
 from Testing.ZopeTestCase import FunctionalDocFileSuite
-from zope.app.testing import setup
 from zope.interface import Interface
 from zope.interface import implements
 from zope.viewlet import interfaces
@@ -77,12 +76,7 @@
     weight = 0
     city = {'name': 'Los Angeles, CA', 'temp': 78}
 
-def setUp(test):
-    setup.placefulSetUp()
 
-def tearDown(test):
-    setup.placefulTearDown()
-
 def test_suite():
     return unittest.TestSuite([
         FunctionalDocFileSuite('README.txt'),

Modified: Zope/trunk/src/Testing/ZopeTestCase/placeless.py
===================================================================
--- Zope/trunk/src/Testing/ZopeTestCase/placeless.py	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/src/Testing/ZopeTestCase/placeless.py	2009-04-26 16:33:20 UTC (rev 99527)
@@ -15,8 +15,42 @@
 $Id$
 """
 
-from zope.app.testing.placelesssetup import setUp, tearDown
+from zope.component.testing import PlacelessSetup as CAPlacelessSetup
+from zope.component.eventtesting import PlacelessSetup as EventPlacelessSetup
+from zope.container.testing import PlacelessSetup as ContainerPlacelessSetup
+from zope.i18n.testing import PlacelessSetup as I18nPlacelessSetup
+from zope.security.management import newInteraction
+from zope.security.testing import addCheckerPublic
 
+
+class PlacelessSetup(CAPlacelessSetup,
+                     EventPlacelessSetup,
+                     I18nPlacelessSetup,
+                     ContainerPlacelessSetup):
+
+    def setUp(self, doctesttest=None):
+        CAPlacelessSetup.setUp(self)
+        EventPlacelessSetup.setUp(self)
+        ContainerPlacelessSetup.setUp(self)
+        I18nPlacelessSetup.setUp(self)
+
+        addCheckerPublic()
+        newInteraction()
+
+
+ps = PlacelessSetup()
+setUp = ps.setUp
+
+def tearDown():
+    tearDown_ = ps.tearDown
+    def tearDown(doctesttest=None):
+        tearDown_()
+    return tearDown
+
+tearDown = tearDown()
+
+del ps
+
 # For convenience
 from Products.Five import zcml
 

Modified: Zope/trunk/src/Zope2/App/tests/testExceptionHook.py
===================================================================
--- Zope/trunk/src/Zope2/App/tests/testExceptionHook.py	2009-04-26 15:02:47 UTC (rev 99526)
+++ Zope/trunk/src/Zope2/App/tests/testExceptionHook.py	2009-04-26 16:33:20 UTC (rev 99527)
@@ -16,16 +16,14 @@
 import unittest
 import logging
 
+from zope.component.testing import PlacelessSetup
 from zope.interface.common.interfaces import IException
 from zope.publisher.skinnable import setDefaultSkin
 from zope.publisher.interfaces import INotFound
 from zope.security.interfaces import IUnauthorized
 from zope.security.interfaces import IForbidden
 
-from zope.app.testing import ztapi
-from zope.app.testing.placelesssetup import PlacelessSetup
 
-
 class ExceptionHookTestCase(unittest.TestCase):
 
     def _makeOne(self):
@@ -329,12 +327,24 @@
     def __call__(self):
         return "Exception View: %s" % self.context.__class__.__name__
 
+def registerExceptionView(for_):
+    from zope.interface import Interface
+    from zope.component import getGlobalSiteManager
+    from zope.publisher.interfaces.browser import IDefaultBrowserLayer
+    gsm = getGlobalSiteManager()
+    gsm.registerAdapter(
+        CustomExceptionView,
+        required=(for_, IDefaultBrowserLayer),
+        provided=Interface,
+        name=u'index.html',
+    )
+
 class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
 
     def testCustomExceptionViewUnauthorized(self):
         from ZPublisher.HTTPResponse import HTTPResponse
         from AccessControl import Unauthorized
-        ztapi.browserView(IUnauthorized, u'index.html', CustomExceptionView)
+        registerExceptionView(IUnauthorized)
         def f():
             raise Unauthorized, 1
         request = self._makeRequest()
@@ -347,7 +357,7 @@
     def testCustomExceptionViewForbidden(self):
         from ZPublisher.HTTPResponse import HTTPResponse
         from zExceptions import Forbidden
-        ztapi.browserView(IForbidden, u'index.html', CustomExceptionView)
+        registerExceptionView(IForbidden)
         def f():
             raise Forbidden, "argh"
         request = self._makeRequest()
@@ -360,7 +370,7 @@
     def testCustomExceptionViewNotFound(self):
         from ZPublisher.HTTPResponse import HTTPResponse
         from zExceptions import NotFound
-        ztapi.browserView(INotFound, u'index.html', CustomExceptionView)
+        registerExceptionView(INotFound)
         def f():
             raise NotFound, "argh"
         request = self._makeRequest()
@@ -373,7 +383,7 @@
     def testCustomExceptionViewBadRequest(self):
         from ZPublisher.HTTPResponse import HTTPResponse
         from zExceptions import BadRequest
-        ztapi.browserView(IException, u'index.html', CustomExceptionView)
+        registerExceptionView(IException)
         def f():
             raise BadRequest, "argh"
         request = self._makeRequest()
@@ -386,7 +396,7 @@
     def testCustomExceptionViewInternalError(self):
         from ZPublisher.HTTPResponse import HTTPResponse
         from zExceptions import InternalError
-        ztapi.browserView(IException, u'index.html', CustomExceptionView)
+        registerExceptionView(IException)
         def f():
             raise InternalError, "argh"
         request = self._makeRequest()
@@ -398,7 +408,7 @@
 
     def testRedirectNoExceptionView(self):
         from zExceptions import Redirect
-        ztapi.browserView(IException, u'index.html', CustomExceptionView)
+        registerExceptionView(IException)
         def f():
             raise Redirect, "http://zope.org/"
         request = self._makeRequest()



More information about the Zope-Checkins mailing list