Commit 3a12502f authored by Hanno Schlichting's avatar Hanno Schlichting

Removed the dependency on `zope.app.testing` in favor of providing a more...

Removed the dependency on `zope.app.testing` in favor of providing a more minimal placeless setup as part of ZopeTestCase for our own tests.
parent 9c0bd8ee
...@@ -65,6 +65,7 @@ eggs = ...@@ -65,6 +65,7 @@ eggs =
zope.app.principalannotation zope.app.principalannotation
zope.app.schema zope.app.schema
zope.app.securitypolicy zope.app.securitypolicy
zope.app.testing
zope.app.zcmlfiles zope.app.zcmlfiles
zope.app.zptpage zope.app.zptpage
python-gettext python-gettext
......
...@@ -8,6 +8,12 @@ file HISTORY.txt. ...@@ -8,6 +8,12 @@ file HISTORY.txt.
Trunk (unreleased) 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 Bugs Fixed
++++++++++ ++++++++++
...@@ -29,17 +35,6 @@ Bugs Fixed ...@@ -29,17 +35,6 @@ Bugs Fixed
The generated tarball for the 2.12.0a2 source release was incomplete, due to The generated tarball for the 2.12.0a2 source release was incomplete, due to
a setuptools and Subversion 1.6 incompatibility. 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 Restructuring
+++++++++++++ +++++++++++++
......
...@@ -143,6 +143,7 @@ params = dict(name='Zope2', ...@@ -143,6 +143,7 @@ params = dict(name='Zope2',
'zope.testing', 'zope.testing',
'zope.traversing', 'zope.traversing',
'zope.viewlet', 'zope.viewlet',
'zope.app.appsetup',
'zope.app.component', 'zope.app.component',
'zope.app.container', 'zope.app.container',
'zope.app.form', 'zope.app.form',
...@@ -151,7 +152,6 @@ params = dict(name='Zope2', ...@@ -151,7 +152,6 @@ params = dict(name='Zope2',
'zope.app.publication', 'zope.app.publication',
'zope.app.publisher', 'zope.app.publisher',
'zope.app.schema', 'zope.app.schema',
'zope.app.testing',
], ],
include_package_data=True, include_package_data=True,
......
import unittest import unittest
from zope.app.testing.placelesssetup import PlacelessSetup from zope.component.testing import PlacelessSetup
from AccessControl.Owned import EmergencyUserCannotOwn from AccessControl.Owned import EmergencyUserCannotOwn
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
......
...@@ -544,7 +544,7 @@ def test_traversable(): ...@@ -544,7 +544,7 @@ def test_traversable():
Clean up: Clean up:
>>> from zope.app.testing.placelesssetup import tearDown >>> from zope.component.testing import tearDown
>>> tearDown() >>> tearDown()
Verify that after cleanup, there's no cruft left from five:traversable:: Verify that after cleanup, there's no cruft left from five:traversable::
...@@ -652,7 +652,7 @@ def test_view_doesnt_shadow_attribute(): ...@@ -652,7 +652,7 @@ def test_view_doesnt_shadow_attribute():
Clean up: Clean up:
>>> from zope.app.testing.placelesssetup import tearDown >>> from zope.component.testing import tearDown
>>> tearDown() >>> tearDown()
""" """
......
...@@ -200,5 +200,5 @@ class variables: ...@@ -200,5 +200,5 @@ class variables:
Clean up Clean up
-------- --------
>>> from zope.app.testing.placelesssetup import tearDown >>> from zope.component.testing import tearDown
>>> tearDown() >>> tearDown()
...@@ -330,5 +330,5 @@ Test traversal to resources from within ZPT pages: ...@@ -330,5 +330,5 @@ Test traversal to resources from within ZPT pages:
Clean up Clean up
-------- --------
>>> from zope.app.testing.placelesssetup import tearDown >>> from zope.component.testing import tearDown
>>> tearDown() >>> tearDown()
...@@ -156,5 +156,5 @@ or a __call__ object that's callable, such as a ViewPageTemplateFile: ...@@ -156,5 +156,5 @@ or a __call__ object that's callable, such as a ViewPageTemplateFile:
Clean up Clean up
-------- --------
>>> from zope.app.testing.placelesssetup import tearDown >>> from zope.component.testing import tearDown
>>> tearDown() >>> tearDown()
...@@ -112,5 +112,5 @@ We can now view them all: ...@@ -112,5 +112,5 @@ We can now view them all:
Clean up Clean up
-------- --------
>>> from zope.app.testing.placelesssetup import tearDown >>> from zope.component.testing import tearDown
>>> tearDown() >>> tearDown()
...@@ -130,5 +130,5 @@ We also can traverse into sub-directories: ...@@ -130,5 +130,5 @@ We also can traverse into sub-directories:
Clean up Clean up
-------- --------
>>> from zope.app.testing.placelesssetup import tearDown >>> from zope.component.testing import tearDown
>>> tearDown() >>> tearDown()
...@@ -50,5 +50,5 @@ Or when we make that skin the default skin: ...@@ -50,5 +50,5 @@ Or when we make that skin the default skin:
Clean up Clean up
-------- --------
>>> from zope.app.testing.placelesssetup import tearDown >>> from zope.component.testing import tearDown
>>> tearDown() >>> tearDown()
...@@ -81,7 +81,7 @@ def test_absoluteurl(): ...@@ -81,7 +81,7 @@ def test_absoluteurl():
Clean up: Clean up:
>>> from zope.app.testing.placelesssetup import tearDown >>> from zope.component.testing import tearDown
>>> tearDown() >>> tearDown()
""" """
......
...@@ -81,7 +81,7 @@ def test_default_view(): ...@@ -81,7 +81,7 @@ def test_default_view():
Clean up: Clean up:
>>> from zope.app.testing.placelesssetup import tearDown >>> from zope.component.testing import tearDown
>>> tearDown() >>> tearDown()
""" """
......
...@@ -80,7 +80,7 @@ def test_zpt_i18n(): ...@@ -80,7 +80,7 @@ def test_zpt_i18n():
Clean up: Clean up:
>>> from zope.app.testing.placelesssetup import tearDown >>> from zope.component.testing import tearDown
>>> tearDown() >>> tearDown()
""" """
......
...@@ -166,7 +166,7 @@ def test_menu(): ...@@ -166,7 +166,7 @@ def test_menu():
Clean up: Clean up:
>>> from zope.app.testing.placelesssetup import tearDown >>> from zope.component.testing import tearDown
>>> tearDown() >>> tearDown()
""" """
......
...@@ -61,7 +61,7 @@ def test_view_with_unwrapped_context(): ...@@ -61,7 +61,7 @@ def test_view_with_unwrapped_context():
Clean up: Clean up:
>>> from zope.app.testing.placelesssetup import tearDown >>> from zope.component.testing import tearDown
>>> tearDown() >>> tearDown()
""" """
......
...@@ -161,7 +161,7 @@ def test_traversable(): ...@@ -161,7 +161,7 @@ def test_traversable():
Clean up: Clean up:
>>> from zope.app.testing.placelesssetup import tearDown >>> from zope.component.testing import tearDown
>>> tearDown() >>> tearDown()
Verify that after cleanup, there's no cruft left from five:traversable:: Verify that after cleanup, there's no cruft left from five:traversable::
...@@ -278,7 +278,7 @@ def test_view_doesnt_shadow_attribute(): ...@@ -278,7 +278,7 @@ def test_view_doesnt_shadow_attribute():
Clean up: Clean up:
>>> from zope.app.testing.placelesssetup import tearDown >>> from zope.component.testing import tearDown
>>> tearDown() >>> tearDown()
""" """
......
...@@ -48,7 +48,7 @@ def test_check_permission(): ...@@ -48,7 +48,7 @@ def test_check_permission():
Clean up: Clean up:
>>> from zope.app.testing.placelesssetup import tearDown >>> from zope.component.testing import tearDown
>>> tearDown() >>> tearDown()
""" """
......
...@@ -568,5 +568,5 @@ Clean up ...@@ -568,5 +568,5 @@ Clean up
Finally, we need to clean up: Finally, we need to clean up:
>>> from zope.app.testing.placelesssetup import tearDown >>> from zope.component.testing import tearDown
>>> tearDown() >>> tearDown()
...@@ -53,7 +53,7 @@ def test_get_widgets_for_schema_fields(): ...@@ -53,7 +53,7 @@ def test_get_widgets_for_schema_fields():
Clean up: Clean up:
>>> from zope.app.testing.placelesssetup import tearDown >>> from zope.component.testing import tearDown
>>> tearDown() >>> tearDown()
""" """
......
...@@ -82,5 +82,5 @@ Clean up ...@@ -82,5 +82,5 @@ Clean up
Finally, we need to clean up: Finally, we need to clean up:
>>> from zope.app.testing.placelesssetup import tearDown >>> from zope.component.testing import tearDown
>>> tearDown() >>> tearDown()
...@@ -69,7 +69,7 @@ def test_standard_macros(): ...@@ -69,7 +69,7 @@ def test_standard_macros():
Clean up: Clean up:
>>> from zope.app.testing.placelesssetup import tearDown >>> from zope.component.testing import tearDown
>>> tearDown() >>> tearDown()
""" """
......
...@@ -18,7 +18,7 @@ $Id$ ...@@ -18,7 +18,7 @@ $Id$
def test_boilerplate(): def test_boilerplate():
""" """
>>> from zope.app.testing.placelesssetup import setUp, tearDown >>> from zope.component.testing import setUp, tearDown
>>> setUp() >>> setUp()
>>> import Products.Five.tests >>> import Products.Five.tests
......
...@@ -20,7 +20,7 @@ def test_registerClass(): ...@@ -20,7 +20,7 @@ def test_registerClass():
""" """
Testing registerClass Testing registerClass
>>> from zope.app.testing.placelesssetup import setUp, tearDown >>> from zope.component.testing import setUp, tearDown
>>> setUp() >>> setUp()
>>> import Products >>> import Products
>>> import Products.Five >>> import Products.Five
......
...@@ -26,7 +26,7 @@ def test_registerPackage(): ...@@ -26,7 +26,7 @@ def test_registerPackage():
""" """
Testing registerPackage Testing registerPackage
>>> from zope.app.testing.placelesssetup import setUp, tearDown >>> from zope.component.testing import setUp, tearDown
>>> setUp() >>> setUp()
>>> import Products >>> import Products
>>> import Products.Five >>> import Products.Five
......
...@@ -67,7 +67,7 @@ def test_security_equivalence(): ...@@ -67,7 +67,7 @@ def test_security_equivalence():
Zope 2 can be replaced by ZCML statements without any loss of Zope 2 can be replaced by ZCML statements without any loss of
information. information.
>>> from zope.app.testing.placelesssetup import setUp, tearDown >>> from zope.component.testing import setUp, tearDown
>>> setUp() >>> setUp()
We start out with two classes, ``Dummy1`` and ``Dummy2``. They We start out with two classes, ``Dummy1`` and ``Dummy2``. They
...@@ -162,7 +162,7 @@ def test_allowed_interface(): ...@@ -162,7 +162,7 @@ def test_allowed_interface():
"""This test demonstrates that allowed_interface security declarations work """This test demonstrates that allowed_interface security declarations work
as expected. as expected.
>>> from zope.app.testing.placelesssetup import setUp, tearDown >>> from zope.component.testing import setUp, tearDown
>>> setUp() >>> setUp()
Before we can make security declarations through ZCML, we need to Before we can make security declarations through ZCML, we need to
...@@ -236,7 +236,7 @@ def test_set_warnings(): ...@@ -236,7 +236,7 @@ def test_set_warnings():
Zope 2, but we want to be able to re-use pure Zope 3 packages that use Zope 2, but we want to be able to re-use pure Zope 3 packages that use
them without error. them without error.
>>> from zope.app.testing.placelesssetup import setUp, tearDown >>> from zope.component.testing import setUp, tearDown
>>> setUp() >>> setUp()
Before we can make security declarations through ZCML, we need to Before we can make security declarations through ZCML, we need to
...@@ -284,7 +284,7 @@ def test_checkPermission(): ...@@ -284,7 +284,7 @@ def test_checkPermission():
""" """
Test checkPermission Test checkPermission
>>> from zope.app.testing.placelesssetup import setUp, tearDown >>> from zope.component.testing import setUp, tearDown
>>> setUp() >>> setUp()
Zope 3 has a function zope.security.checkPermission which provides Zope 3 has a function zope.security.checkPermission which provides
...@@ -379,7 +379,7 @@ def test_register_permission(): ...@@ -379,7 +379,7 @@ def test_register_permission():
to create a permission that does not already exist, it is created on to create a permission that does not already exist, it is created on
startup, with roles defaulting to Manager. startup, with roles defaulting to Manager.
>>> from zope.app.testing.placelesssetup import setUp, tearDown >>> from Testing.ZopeTestCase.placeless import setUp, tearDown
>>> setUp() >>> setUp()
First, we need to configure the relevant parts of Five. First, we need to configure the relevant parts of Five.
......
...@@ -51,7 +51,7 @@ def test_size(): ...@@ -51,7 +51,7 @@ def test_size():
Set up: Set up:
>>> from zope.app.testing.placelesssetup import setUp, tearDown >>> from zope.component.testing import setUp, tearDown
>>> setUp() >>> setUp()
>>> configure_zcml = ''' >>> configure_zcml = '''
......
...@@ -20,7 +20,7 @@ def test_editview(): ...@@ -20,7 +20,7 @@ def test_editview():
""" """
Set everything up: Set everything up:
>>> from zope.app.testing.placelesssetup import setUp, tearDown >>> from zope.component.testing import setUp, tearDown
>>> setUp() >>> setUp()
>>> import Products.Five >>> import Products.Five
>>> import Products.Five.utilities >>> import Products.Five.utilities
......
...@@ -361,6 +361,18 @@ links into HTML headers, since those two are so very common. I am only going ...@@ -361,6 +361,18 @@ links into HTML headers, since those two are so very common. I am only going
to demonstrate the helper functions here, since those demonstrations will to demonstrate the helper functions here, since those demonstrations will
fully demonstrate the functionality of the base classes as well. 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 The viewlet will look up the resource it was given and tries to produce the
absolute URL for it: absolute URL for it:
...@@ -371,8 +383,7 @@ absolute URL for it: ...@@ -371,8 +383,7 @@ absolute URL for it:
... def __call__(self): ... def __call__(self):
... return '/@@/resource.js' ... return '/@@/resource.js'
>>> from zope.app.testing import ztapi >>> registerResource('resource.js', JSResource)
>>> ztapi.browserResource('resource.js', JSResource)
>>> JSViewlet = viewlet.JavaScriptViewlet('resource.js') >>> JSViewlet = viewlet.JavaScriptViewlet('resource.js')
>>> print JSViewlet(content, request, view, manager).render().strip() >>> print JSViewlet(content, request, view, manager).render().strip()
<script type="text/javascript" src="/@@/resource.js"> <script type="text/javascript" src="/@@/resource.js">
...@@ -387,7 +398,7 @@ The same works for the CSS resource viewlet: ...@@ -387,7 +398,7 @@ The same works for the CSS resource viewlet:
... def __call__(self): ... def __call__(self):
... return '/@@/resource.css' ... return '/@@/resource.css'
>>> ztapi.browserResource('resource.css', CSSResource) >>> registerResource('resource.css', CSSResource)
>>> CSSViewlet = viewlet.CSSViewlet('resource.css') >>> CSSViewlet = viewlet.CSSViewlet('resource.css')
>>> print CSSViewlet(content, request, view, manager).render().strip() >>> print CSSViewlet(content, request, view, manager).render().strip()
......
...@@ -19,7 +19,6 @@ __docformat__ = 'restructuredtext' ...@@ -19,7 +19,6 @@ __docformat__ = 'restructuredtext'
import unittest import unittest
from Testing.ZopeTestCase import FunctionalDocFileSuite from Testing.ZopeTestCase import FunctionalDocFileSuite
from zope.app.testing import setup
from zope.interface import Interface from zope.interface import Interface
from zope.interface import implements from zope.interface import implements
from zope.viewlet import interfaces from zope.viewlet import interfaces
...@@ -77,11 +76,6 @@ class DynamicTempBox(object): ...@@ -77,11 +76,6 @@ class DynamicTempBox(object):
weight = 0 weight = 0
city = {'name': 'Los Angeles, CA', 'temp': 78} city = {'name': 'Los Angeles, CA', 'temp': 78}
def setUp(test):
setup.placefulSetUp()
def tearDown(test):
setup.placefulTearDown()
def test_suite(): def test_suite():
return unittest.TestSuite([ return unittest.TestSuite([
......
...@@ -15,7 +15,41 @@ ...@@ -15,7 +15,41 @@
$Id$ $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 # For convenience
from Products.Five import zcml from Products.Five import zcml
......
...@@ -16,15 +16,13 @@ import sys ...@@ -16,15 +16,13 @@ import sys
import unittest import unittest
import logging import logging
from zope.component.testing import PlacelessSetup
from zope.interface.common.interfaces import IException from zope.interface.common.interfaces import IException
from zope.publisher.skinnable import setDefaultSkin from zope.publisher.skinnable import setDefaultSkin
from zope.publisher.interfaces import INotFound from zope.publisher.interfaces import INotFound
from zope.security.interfaces import IUnauthorized from zope.security.interfaces import IUnauthorized
from zope.security.interfaces import IForbidden from zope.security.interfaces import IForbidden
from zope.app.testing import ztapi
from zope.app.testing.placelesssetup import PlacelessSetup
class ExceptionHookTestCase(unittest.TestCase): class ExceptionHookTestCase(unittest.TestCase):
...@@ -329,12 +327,24 @@ class CustomExceptionView: ...@@ -329,12 +327,24 @@ class CustomExceptionView:
def __call__(self): def __call__(self):
return "Exception View: %s" % self.context.__class__.__name__ 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): class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
def testCustomExceptionViewUnauthorized(self): def testCustomExceptionViewUnauthorized(self):
from ZPublisher.HTTPResponse import HTTPResponse from ZPublisher.HTTPResponse import HTTPResponse
from AccessControl import Unauthorized from AccessControl import Unauthorized
ztapi.browserView(IUnauthorized, u'index.html', CustomExceptionView) registerExceptionView(IUnauthorized)
def f(): def f():
raise Unauthorized, 1 raise Unauthorized, 1
request = self._makeRequest() request = self._makeRequest()
...@@ -347,7 +357,7 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase): ...@@ -347,7 +357,7 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
def testCustomExceptionViewForbidden(self): def testCustomExceptionViewForbidden(self):
from ZPublisher.HTTPResponse import HTTPResponse from ZPublisher.HTTPResponse import HTTPResponse
from zExceptions import Forbidden from zExceptions import Forbidden
ztapi.browserView(IForbidden, u'index.html', CustomExceptionView) registerExceptionView(IForbidden)
def f(): def f():
raise Forbidden, "argh" raise Forbidden, "argh"
request = self._makeRequest() request = self._makeRequest()
...@@ -360,7 +370,7 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase): ...@@ -360,7 +370,7 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
def testCustomExceptionViewNotFound(self): def testCustomExceptionViewNotFound(self):
from ZPublisher.HTTPResponse import HTTPResponse from ZPublisher.HTTPResponse import HTTPResponse
from zExceptions import NotFound from zExceptions import NotFound
ztapi.browserView(INotFound, u'index.html', CustomExceptionView) registerExceptionView(INotFound)
def f(): def f():
raise NotFound, "argh" raise NotFound, "argh"
request = self._makeRequest() request = self._makeRequest()
...@@ -373,7 +383,7 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase): ...@@ -373,7 +383,7 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
def testCustomExceptionViewBadRequest(self): def testCustomExceptionViewBadRequest(self):
from ZPublisher.HTTPResponse import HTTPResponse from ZPublisher.HTTPResponse import HTTPResponse
from zExceptions import BadRequest from zExceptions import BadRequest
ztapi.browserView(IException, u'index.html', CustomExceptionView) registerExceptionView(IException)
def f(): def f():
raise BadRequest, "argh" raise BadRequest, "argh"
request = self._makeRequest() request = self._makeRequest()
...@@ -386,7 +396,7 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase): ...@@ -386,7 +396,7 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
def testCustomExceptionViewInternalError(self): def testCustomExceptionViewInternalError(self):
from ZPublisher.HTTPResponse import HTTPResponse from ZPublisher.HTTPResponse import HTTPResponse
from zExceptions import InternalError from zExceptions import InternalError
ztapi.browserView(IException, u'index.html', CustomExceptionView) registerExceptionView(IException)
def f(): def f():
raise InternalError, "argh" raise InternalError, "argh"
request = self._makeRequest() request = self._makeRequest()
...@@ -398,7 +408,7 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase): ...@@ -398,7 +408,7 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
def testRedirectNoExceptionView(self): def testRedirectNoExceptionView(self):
from zExceptions import Redirect from zExceptions import Redirect
ztapi.browserView(IException, u'index.html', CustomExceptionView) registerExceptionView(IException)
def f(): def f():
raise Redirect, "http://zope.org/" raise Redirect, "http://zope.org/"
request = self._makeRequest() request = self._makeRequest()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment