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 =
zope.app.principalannotation
zope.app.schema
zope.app.securitypolicy
zope.app.testing
zope.app.zcmlfiles
zope.app.zptpage
python-gettext
......
......@@ -8,6 +8,12 @@ file HISTORY.txt.
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 @@ Bugs Fixed
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
+++++++++++++
......
......@@ -143,6 +143,7 @@ params = dict(name='Zope2',
'zope.testing',
'zope.traversing',
'zope.viewlet',
'zope.app.appsetup',
'zope.app.component',
'zope.app.container',
'zope.app.form',
......@@ -151,7 +152,6 @@ params = dict(name='Zope2',
'zope.app.publication',
'zope.app.publisher',
'zope.app.schema',
'zope.app.testing',
],
include_package_data=True,
......
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
......
......@@ -544,7 +544,7 @@ def test_traversable():
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 @@ def test_view_doesnt_shadow_attribute():
Clean up:
>>> from zope.app.testing.placelesssetup import tearDown
>>> from zope.component.testing import tearDown
>>> tearDown()
"""
......
......@@ -200,5 +200,5 @@ class variables:
Clean up
--------
>>> from zope.app.testing.placelesssetup import tearDown
>>> from zope.component.testing import tearDown
>>> tearDown()
......@@ -330,5 +330,5 @@ Test traversal to resources from within ZPT pages:
Clean up
--------
>>> from zope.app.testing.placelesssetup import tearDown
>>> from zope.component.testing import tearDown
>>> tearDown()
......@@ -156,5 +156,5 @@ or a __call__ object that's callable, such as a ViewPageTemplateFile:
Clean up
--------
>>> from zope.app.testing.placelesssetup import tearDown
>>> from zope.component.testing import tearDown
>>> tearDown()
......@@ -112,5 +112,5 @@ We can now view them all:
Clean up
--------
>>> from zope.app.testing.placelesssetup import tearDown
>>> from zope.component.testing import tearDown
>>> tearDown()
......@@ -130,5 +130,5 @@ We also can traverse into sub-directories:
Clean up
--------
>>> from zope.app.testing.placelesssetup import tearDown
>>> from zope.component.testing import tearDown
>>> tearDown()
......@@ -50,5 +50,5 @@ Or when we make that skin the default skin:
Clean up
--------
>>> from zope.app.testing.placelesssetup import tearDown
>>> from zope.component.testing import tearDown
>>> tearDown()
......@@ -81,7 +81,7 @@ def test_absoluteurl():
Clean up:
>>> from zope.app.testing.placelesssetup import tearDown
>>> from zope.component.testing import tearDown
>>> tearDown()
"""
......
......@@ -81,7 +81,7 @@ def test_default_view():
Clean up:
>>> from zope.app.testing.placelesssetup import tearDown
>>> from zope.component.testing import tearDown
>>> tearDown()
"""
......
......@@ -80,7 +80,7 @@ def test_zpt_i18n():
Clean up:
>>> from zope.app.testing.placelesssetup import tearDown
>>> from zope.component.testing import tearDown
>>> tearDown()
"""
......
......@@ -166,7 +166,7 @@ def test_menu():
Clean up:
>>> from zope.app.testing.placelesssetup import tearDown
>>> from zope.component.testing import tearDown
>>> tearDown()
"""
......
......@@ -61,7 +61,7 @@ def test_view_with_unwrapped_context():
Clean up:
>>> from zope.app.testing.placelesssetup import tearDown
>>> from zope.component.testing import tearDown
>>> tearDown()
"""
......
......@@ -161,7 +161,7 @@ def test_traversable():
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 @@ def test_view_doesnt_shadow_attribute():
Clean up:
>>> from zope.app.testing.placelesssetup import tearDown
>>> from zope.component.testing import tearDown
>>> tearDown()
"""
......
......@@ -48,7 +48,7 @@ def test_check_permission():
Clean up:
>>> from zope.app.testing.placelesssetup import tearDown
>>> from zope.component.testing import tearDown
>>> tearDown()
"""
......
......@@ -568,5 +568,5 @@ Clean up
Finally, we need to clean up:
>>> from zope.app.testing.placelesssetup import tearDown
>>> from zope.component.testing import tearDown
>>> tearDown()
......@@ -53,7 +53,7 @@ def test_get_widgets_for_schema_fields():
Clean up:
>>> from zope.app.testing.placelesssetup import tearDown
>>> from zope.component.testing import tearDown
>>> tearDown()
"""
......
......@@ -82,5 +82,5 @@ Clean up
Finally, we need to clean up:
>>> from zope.app.testing.placelesssetup import tearDown
>>> from zope.component.testing import tearDown
>>> tearDown()
......@@ -69,7 +69,7 @@ def test_standard_macros():
Clean up:
>>> from zope.app.testing.placelesssetup import tearDown
>>> from zope.component.testing import tearDown
>>> tearDown()
"""
......
......@@ -18,7 +18,7 @@ $Id$
def test_boilerplate():
"""
>>> from zope.app.testing.placelesssetup import setUp, tearDown
>>> from zope.component.testing import setUp, tearDown
>>> setUp()
>>> import Products.Five.tests
......
......@@ -20,7 +20,7 @@ def test_registerClass():
"""
Testing registerClass
>>> from zope.app.testing.placelesssetup import setUp, tearDown
>>> from zope.component.testing import setUp, tearDown
>>> setUp()
>>> import Products
>>> import Products.Five
......
......@@ -26,7 +26,7 @@ def test_registerPackage():
"""
Testing registerPackage
>>> from zope.app.testing.placelesssetup import setUp, tearDown
>>> from zope.component.testing import setUp, tearDown
>>> setUp()
>>> import Products
>>> import Products.Five
......
......@@ -67,7 +67,7 @@ def test_security_equivalence():
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 @@ def test_allowed_interface():
"""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 @@ def test_set_warnings():
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 @@ def test_checkPermission():
"""
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 @@ def test_register_permission():
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.
......
......@@ -51,7 +51,7 @@ def test_size():
Set up:
>>> from zope.app.testing.placelesssetup import setUp, tearDown
>>> from zope.component.testing import setUp, tearDown
>>> setUp()
>>> configure_zcml = '''
......
......@@ -20,7 +20,7 @@ def test_editview():
"""
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
......
......@@ -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
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 @@ absolute URL for it:
... 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 @@ The same works for the CSS resource viewlet:
... 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()
......
......@@ -19,7 +19,6 @@ __docformat__ = 'restructuredtext'
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,11 +76,6 @@ class DynamicTempBox(object):
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([
......
......@@ -15,7 +15,41 @@
$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
......
......@@ -16,15 +16,13 @@ import sys
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):
......@@ -329,12 +327,24 @@ class CustomExceptionView:
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 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
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 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
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 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
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 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
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 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
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()
......
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