[Checkins] SVN: grok/trunk/ Merge the testlayers branch. This allows us to lose the dependency of
Martijn Faassen
faassen at startifact.com
Mon Jul 5 13:38:32 EDT 2010
Log message for revision 114216:
Merge the testlayers branch. This allows us to lose the dependency of
Grok on zope.app.testing and, as a consequence, on a whole of other
packages, mostly zope.app.* related.
The tests work but for one test failure, which is worrying: an
exception view doesn't seem to be kicking in.
An old testsetup setup was also removed from Grok's configuration in this
branch (in favor of z3c.testsetup).
Changed:
U grok/trunk/CHANGES.txt
U grok/trunk/doc/upgrade.txt
U grok/trunk/setup.py
U grok/trunk/src/grok/components.py
U grok/trunk/src/grok/configure.zcml
U grok/trunk/src/grok/ftests/catalog/addform.py
U grok/trunk/src/grok/ftests/catalog/catalog.py
U grok/trunk/src/grok/ftests/catalog/setuporder.py
U grok/trunk/src/grok/ftests/form/form.py
U grok/trunk/src/grok/ftests/json/json.py
U grok/trunk/src/grok/ftests/rest/localgrants.py
U grok/trunk/src/grok/ftests/rest/rest.py
U grok/trunk/src/grok/ftests/security/grok_view.py
U grok/trunk/src/grok/ftests/security/handle_exception.py
U grok/trunk/src/grok/ftests/security/json.py
U grok/trunk/src/grok/ftests/security/preserve_permissions.py
U grok/trunk/src/grok/ftests/security/roles.py
U grok/trunk/src/grok/ftests/security/security_view.py
U grok/trunk/src/grok/ftests/test_grok_functional.py
U grok/trunk/src/grok/ftests/traversal/containertraverse.py
U grok/trunk/src/grok/ftests/traversal/containertraverser.py
U grok/trunk/src/grok/ftests/traversal/items_before_views.py
U grok/trunk/src/grok/ftests/traversal/modeltraverse.py
U grok/trunk/src/grok/ftests/traversal/traversableattr.py
U grok/trunk/src/grok/ftests/traversal/traverser.py
U grok/trunk/src/grok/ftests/traversal/traverser_sets_parent.py
U grok/trunk/src/grok/ftests/url/application.py
U grok/trunk/src/grok/ftests/viewlet/viewlet_security.py
U grok/trunk/src/grok/ftests/xmlrpc/require.py
U grok/trunk/src/grok/ftests/xmlrpc/xmlrpc.py
U grok/trunk/src/grok/meta.py
U grok/trunk/src/grok/testing.py
U grok/trunk/src/grok/tests/test_grok.py
D grok/trunk/src/grok/tests/testsetup/
-=-
Modified: grok/trunk/CHANGES.txt
===================================================================
--- grok/trunk/CHANGES.txt 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/CHANGES.txt 2010-07-05 17:38:31 UTC (rev 114216)
@@ -4,7 +4,9 @@
1.2 (unreleased)
================
-* ...
+* Removed z3c.testsetup-specific test collector from grok.testing. You
+ can still use z3c.testsetup with grok, but have to declare the
+ dependency in your project's ``setup.py`` explicitly.
1.1rc1 (2010-02-25)
===================
Modified: grok/trunk/doc/upgrade.txt
===================================================================
--- grok/trunk/doc/upgrade.txt 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/doc/upgrade.txt 2010-07-05 17:38:31 UTC (rev 114216)
@@ -11,6 +11,21 @@
**Warning**. Please be sure to always backup your data (especially the
``Data.fs`` file) before you perform upgrades.
+.. _upgrade_notes_1.1:
+
+Upgrading to 1.1 (unreleased)
+-----------------------------
+
+* `z3c.testsetup` dependency has been removed from grok. If you use
+ grok.testing.register_all_tests in your testsetup, make sure to
+ require ``z3c.testsetup`` (and also ``zope.app.testing``, if you use
+ functional tests) in `setup.py` of your project and use::
+
+ import z3c.testsetsetup
+ z3c.testsetup.register_all_tests(...)
+
+ where you used ``grok.testing.register_all_tests(...)`` before.
+
.. _upgrade_notes_1.1rc1:
Upgrading to 1.1rc1 (2010-02-25)
Modified: grok/trunk/setup.py
===================================================================
--- grok/trunk/setup.py 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/setup.py 2010-07-05 17:38:31 UTC (rev 114216)
@@ -14,9 +14,8 @@
)
tests_require = [
- 'zope.app.testing',
+ 'zope.app.wsgi',
'zope.configuration',
- 'zope.testbrowser',
'zope.testing',
]
@@ -41,65 +40,54 @@
package_dir = {'': 'src'},
include_package_data = True,
zip_safe=False,
- install_requires=['setuptools',
- 'ZODB3',
- 'grokcore.annotation >= 1.1',
- 'grokcore.component >= 1.5, < 2.0',
- 'grokcore.formlib >= 1.4',
- 'grokcore.security >= 1.1',
- 'grokcore.site',
- 'grokcore.content',
- 'grokcore.view >= 1.12',
- 'grokcore.viewlet >= 1.3',
- 'martian >= 0.10, < 0.12',
- 'pytz',
- 'simplejson',
- 'z3c.autoinclude',
- 'z3c.flashmessage',
- 'z3c.testsetup',
- 'zc.catalog',
- 'zope.annotation',
- 'zope.app.publication',
- 'zope.app.publisher',
- 'zope.app.renderer',
- 'zope.app.zcmlfiles',
- 'zope.catalog',
- 'zope.component',
- 'zope.container',
- 'zope.contentprovider',
- 'zope.copypastemove',
- 'zope.event',
- 'zope.exceptions',
- 'zope.formlib',
- 'zope.i18n',
- 'zope.interface',
- 'zope.intid',
- 'zope.keyreference',
- 'zope.lifecycleevent',
- 'zope.location',
- 'zope.password',
- 'zope.pluggableauth',
- 'zope.publisher',
- 'zope.schema',
- 'zope.security',
- 'zope.securitypolicy',
- 'zope.site',
- 'zope.size',
- 'zope.traversing',
- # Reported as unused by z3c.dependencychecker. Should
- # be removed or moved to the deprecated packages list.
- 'zope.app.appsetup',
- 'zope.app.pagetemplate',
- 'zope.app.security',
- 'zope.app.twisted',
- 'zope.deprecation',
- 'zope.dottedname',
- 'zope.hookable',
- 'zope.i18nmessageid',
- 'zope.pagetemplate',
- 'zope.proxy',
- 'zope.viewlet',
- ],
+ install_requires=[
+ 'setuptools',
+ 'ZODB3',
+ 'grokcore.annotation >= 1.1',
+ 'grokcore.component >= 1.5, < 2.0',
+ 'grokcore.content',
+ 'grokcore.formlib >= 1.4',
+ 'grokcore.security >= 1.1',
+ 'grokcore.site',
+ 'grokcore.view >= 1.12',
+ 'grokcore.viewlet >= 1.3',
+ 'martian >= 0.10, < 0.12',
+ 'pytz',
+ 'simplejson',
+ 'z3c.autoinclude',
+ 'z3c.flashmessage',
+ 'zc.catalog',
+ 'zope.annotation',
+ 'zope.app.appsetup',
+ 'zope.app.http',
+ 'zope.app.publication',
+ 'zope.browserpage',
+ 'zope.catalog',
+ 'zope.component',
+ 'zope.container',
+ 'zope.copypastemove',
+ 'zope.dottedname',
+ 'zope.event',
+ 'zope.exceptions',
+ 'zope.i18n',
+ 'zope.i18nmessageid',
+ 'zope.interface',
+ 'zope.intid',
+ 'zope.keyreference',
+ 'zope.lifecycleevent',
+ 'zope.location',
+ 'zope.pagetemplate',
+ 'zope.password',
+ 'zope.pluggableauth',
+ 'zope.principalregistry',
+ 'zope.proxy',
+ 'zope.publisher',
+ 'zope.schema',
+ 'zope.security',
+ 'zope.securitypolicy',
+ 'zope.site',
+ 'zope.traversing',
+ ],
tests_require=tests_require,
extras_require={'test': tests_require},
)
Modified: grok/trunk/src/grok/components.py
===================================================================
--- grok/trunk/src/grok/components.py 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/src/grok/components.py 2010-07-05 17:38:31 UTC (rev 114216)
@@ -31,7 +31,7 @@
from zope.publisher.publish import mapply
from zope.annotation.interfaces import IAttributeAnnotatable
-from zope.app.publisher.browser import getDefaultViewName
+from zope.publisher.defaultview import getDefaultViewName
from zope.container.btree import BTreeContainer
from zope.container.contained import Contained
from zope.container.interfaces import IReadContainer
Modified: grok/trunk/src/grok/configure.zcml
===================================================================
--- grok/trunk/src/grok/configure.zcml 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/src/grok/configure.zcml 2010-07-05 17:38:31 UTC (rev 114216)
@@ -3,35 +3,47 @@
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:grok="http://namespaces.zope.org/grok">
+ <include package="zope.app.publication" file="meta.zcml" />
+ <include package="zope.browserpage" file="meta.zcml" />
+ <include package="zope.component" file="meta.zcml" />
+ <include package="zope.i18n" file="meta.zcml" />
+ <include package="zope.principalregistry" file="meta.zcml" />
+ <include package="zope.publisher" file="meta.zcml" />
<include package="zope.security" file="meta.zcml" />
- <include package="zope.i18n" file="meta.zcml" />
<include package="zope.securitypolicy" file="meta.zcml" />
- <include package="zope.app.zcmlfiles" file="meta.zcml" />
+
<include package="grok" file="meta.zcml" />
+ <include package="zope.app.appsetup" />
+ <include package="zope.app.http" />
+ <include package="zope.app.publication" />
+ <include package="zope.app.wsgi" />
+ <include package="zope.annotation" />
+ <include package="zope.browserpage" />
<include package="zope.catalog" />
+ <include package="zope.component" />
+ <include package="zope.contentprovider" />
<include package="zope.copypastemove" />
- <include package="zope.contentprovider" />
- <include package="zope.formlib" />
+ <include package="zope.i18n.locales" />
<include package="zope.intid" />
- <include package="zope.i18n.locales" />
<include package="zope.keyreference" />
+ <include package="zope.location" />
+ <include package="zope.login" />
<include package="zope.password" />
+ <include package="zope.principalregistry" />
<include package="zope.publisher" />
+ <include package="zope.security " />
<include package="zope.securitypolicy" />
<include package="zope.session" />
- <include package="zope.size" />
+ <include package="zope.site" />
<include package="zope.traversing" />
<include package="zope.traversing.browser" />
- <include package="zope.app.zcmlfiles" />
- <include package="zope.app.renderer" />
-
+ <include package="grokcore.annotation" />
+ <include package="grokcore.formlib" />
+ <include package="grokcore.site" />
<include package="grokcore.view" />
<include package="grokcore.viewlet" />
- <include package="grokcore.formlib" />
- <include package="grokcore.annotation" />
- <include package="grokcore.site" />
<securityPolicy
component="zope.securitypolicy.zopepolicy.ZopeSecurityPolicy" />
Modified: grok/trunk/src/grok/ftests/catalog/addform.py
===================================================================
--- grok/trunk/src/grok/ftests/catalog/addform.py 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/src/grok/ftests/catalog/addform.py 2010-07-05 17:38:31 UTC (rev 114216)
@@ -4,7 +4,7 @@
>>> getRootFolder()["zoo"] = Zoo()
- >>> from zope.testbrowser.testing import Browser
+ >>> from zope.app.wsgi.testlayer import Browser
>>> browser = Browser()
>>> browser.handleErrors = False
Modified: grok/trunk/src/grok/ftests/catalog/catalog.py
===================================================================
--- grok/trunk/src/grok/ftests/catalog/catalog.py 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/src/grok/ftests/catalog/catalog.py 2010-07-05 17:38:31 UTC (rev 114216)
@@ -20,6 +20,17 @@
... print obj.name
Ellie
+Nuke the catalog and intids in the end, so as not to confuse
+other tests::
+
+ >>> from zope import component
+ >>> sm = herd.getSiteManager()
+ >>> sm.unregisterUtility(catalog, provided=ICatalog)
+ True
+ >>> intids = component.getUtility(IIntIds)
+ >>> sm.unregisterUtility(intids, provided=IIntIds)
+ True
+
"""
import grok
Modified: grok/trunk/src/grok/ftests/catalog/setuporder.py
===================================================================
--- grok/trunk/src/grok/ftests/catalog/setuporder.py 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/src/grok/ftests/catalog/setuporder.py 2010-07-05 17:38:31 UTC (rev 114216)
@@ -23,6 +23,17 @@
... print obj.name
Ellie
+Nuke the catalog and intids in the end, so as not to confuse
+other tests::
+
+ >>> from zope import component
+ >>> sm = herd.getSiteManager()
+ >>> sm.unregisterUtility(catalog, provided=ICatalog)
+ True
+ >>> intids = component.getUtility(IIntIds)
+ >>> sm.unregisterUtility(intids, provided=IIntIds)
+ True
+
"""
import grok
Modified: grok/trunk/src/grok/ftests/form/form.py
===================================================================
--- grok/trunk/src/grok/ftests/form/form.py 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/src/grok/ftests/form/form.py 2010-07-05 17:38:31 UTC (rev 114216)
@@ -8,7 +8,7 @@
And we can access the display form which display the application URL::
- >>> from zope.testbrowser.testing import Browser
+ >>> from zope.app.wsgi.testlayer import Browser
>>> browser = Browser()
>>> browser.handleErrors = False
>>> browser.open('http://localhost/world/arthur')
Modified: grok/trunk/src/grok/ftests/json/json.py
===================================================================
--- grok/trunk/src/grok/ftests/json/json.py 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/src/grok/ftests/json/json.py 2010-07-05 17:38:31 UTC (rev 114216)
@@ -4,7 +4,7 @@
JSON views answer a special content-type::
>>> print http('GET /cave/show HTTP/1.1')
- HTTP/1. 200 Ok
+ HTTP/1.0 200 Ok
Content-Length: 17
Content-Type: application/json
<BLANKLINE>
@@ -19,4 +19,4 @@
class CaveJSON(grok.JSON):
def show(self):
- return 'A Cavemans cave'
\ No newline at end of file
+ return 'A Cavemans cave'
Modified: grok/trunk/src/grok/ftests/rest/localgrants.py
===================================================================
--- grok/trunk/src/grok/ftests/rest/localgrants.py 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/src/grok/ftests/rest/localgrants.py 2010-07-05 17:38:31 UTC (rev 114216)
@@ -12,7 +12,7 @@
>>> print http(r'''
... GET /++rest++mammoth/manfred HTTP/1.1
... ''')
- HTTP/1.1 401 Unauthorized
+ HTTP/1.0 401 Unauthorized
Content-Length: 0
Content-Type: text/plain
WWW-Authenticate: basic realm="Zope"
@@ -29,7 +29,7 @@
>>> print http(r'''
... GET /++rest++mammoth/manfred HTTP/1.1
... ''')
- HTTP/1.1 200 Ok
+ HTTP/1.0 200 Ok
Content-Length: 7
Content-Type: text/plain
<BLANKLINE>
Modified: grok/trunk/src/grok/ftests/rest/rest.py
===================================================================
--- grok/trunk/src/grok/ftests/rest/rest.py 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/src/grok/ftests/rest/rest.py 2010-07-05 17:38:31 UTC (rev 114216)
@@ -120,34 +120,34 @@
methods for the requested resource::
>>> print http('POST /++rest++b/app HTTP/1.1')
- HTTP/1. 405 Method Not Allowed
- Allow: GET, PUT
+ HTTP/1.0 405 Method Not Allowed
Content-Length: 18
Content-Type: text/plain
+ Allow: GET, PUT
<BLANKLINE>
Method Not Allowed
>>> print http('DELETE /++rest++b/app HTTP/1.1')
- HTTP/1. 405 Method Not Allowed
+ HTTP/1.0 405 Method Not Allowed
+ Content-Length: 18
Allow: GET, PUT
- Content-Length: 18
<BLANKLINE>
Method Not Allowed
>>> print http('POST /++rest++c/app HTTP/1.1')
- HTTP/1. 405 Method Not Allowed
- Allow:
+ HTTP/1.0 405 Method Not Allowed
Content-Length: 18
Content-Type: text/plain
+ Allow:
<BLANKLINE>
Method Not Allowed
We can also try this with a completely made-up request method, like FROG::
>>> print http('FROG /++rest++b/app HTTP/1.1')
- HTTP/1. 405 Method Not Allowed
+ HTTP/1.0 405 Method Not Allowed
+ Content-Length: 18
Allow: GET, PUT
- Content-Length: 18
<BLANKLINE>
Method Not Allowed
@@ -155,7 +155,7 @@
be public::
>>> print http('GET /++rest++e/app/alpha HTTP/1.1')
- HTTP/1. 200 Ok
+ HTTP/1.0 200 Ok
Content-Length: 4
Content-Type: text/plain
<BLANKLINE>
@@ -164,20 +164,20 @@
POST, PUT and DELETE however are not public::
>>> print http('POST /++rest++e/app/alpha HTTP/1.1')
- HTTP/1. 401 Unauthorized
+ HTTP/1.0 401 Unauthorized
Content-Length: 0
Content-Type: text/plain
WWW-Authenticate: basic realm="Zope"
<BLANKLINE>
>>> print http('PUT /++rest++e/app/alpha HTTP/1.1')
- HTTP/1. 401 Unauthorized
+ HTTP/1.0 401 Unauthorized
Content-Length: 0
WWW-Authenticate: basic realm="Zope"
<BLANKLINE>
>>> print http('DELETE /++rest++e/app/alpha HTTP/1.1')
- HTTP/1. 401 Unauthorized
+ HTTP/1.0 401 Unauthorized
Content-Length: 0
WWW-Authenticate: basic realm="Zope"
<BLANKLINE>
@@ -192,7 +192,7 @@
>>> print http_call('POST', 'http://localhost/++rest++f/app/alpha',
... 'this is the POST body')
- HTTP/1.1 200 Ok
+ HTTP/1.0 200 Ok
Content-Length: 21
Content-Type: text/plain
<BLANKLINE>
@@ -202,7 +202,7 @@
>>> print http_call('PUT', 'http://localhost/++rest++f/app/alpha',
... 'this is the PUT body')
- HTTP/1.1 200 Ok
+ HTTP/1.0 200 Ok
Content-Length: 20
<BLANKLINE>
this is the PUT body
@@ -211,7 +211,7 @@
random objects without access:
>>> print http('DELETE /app HTTP/1.1')
- HTTP/1. 500 Internal Server Error
+ HTTP/1.0 500 Internal Server Error
Content-Length: 127
Content-Type: text/html;charset=utf-8
<BLANKLINE>
@@ -222,7 +222,7 @@
<BLANKLINE>
>>> print http('DELETE /app/alpha HTTP/1.1')
- HTTP/1. 500 Internal Server Error
+ HTTP/1.0 500 Internal Server Error
Content-Length: 127
Content-Type: text/html;charset=utf-8
<BLANKLINE>
@@ -235,7 +235,7 @@
We shouldn't be allowed to PUT either::
>>> print http('PUT /app/beta HTTP/1.1')
- HTTP/1. 404 Not Found
+ HTTP/1.0 404 Not Found
Content-Length: 0
XXX shouldn't this really give a FORBIDDEN response?
Modified: grok/trunk/src/grok/ftests/security/grok_view.py
===================================================================
--- grok/trunk/src/grok/ftests/security/grok_view.py 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/src/grok/ftests/security/grok_view.py 2010-07-05 17:38:31 UTC (rev 114216)
@@ -9,7 +9,7 @@
Now we can look at the view::
- >>> from zope.testbrowser.testing import Browser
+ >>> from zope.app.wsgi.testlayer import Browser
>>> browser = Browser()
>>> browser.handleErrors = False
>>> browser.open('http://localhost/app/@@index')
Modified: grok/trunk/src/grok/ftests/security/handle_exception.py
===================================================================
--- grok/trunk/src/grok/ftests/security/handle_exception.py 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/src/grok/ftests/security/handle_exception.py 2010-07-05 17:38:31 UTC (rev 114216)
@@ -4,7 +4,7 @@
and cause the grok security to fail, we have a simple test here that assures
that we don't hit this:
- >>> from zope.testbrowser.testing import Browser
+ >>> from zope.app.wsgi.testlayer import Browser
>>> browser = Browser()
>>> browser.open("http://localhost/@@cave")
Traceback (most recent call last):
Modified: grok/trunk/src/grok/ftests/security/json.py
===================================================================
--- grok/trunk/src/grok/ftests/security/json.py 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/src/grok/ftests/security/json.py 2010-07-05 17:38:31 UTC (rev 114216)
@@ -1,7 +1,7 @@
"""
Let's test whether require decorators work for json methods.
- >>> from zope.testbrowser.testing import Browser
+ >>> from zope.app.wsgi.testlayer import Browser
>>> browser = Browser()
We can access the public method just fine::
Modified: grok/trunk/src/grok/ftests/security/preserve_permissions.py
===================================================================
--- grok/trunk/src/grok/ftests/security/preserve_permissions.py 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/src/grok/ftests/security/preserve_permissions.py 2010-07-05 17:38:31 UTC (rev 114216)
@@ -3,6 +3,29 @@
Permissions already set by non-grok components are preserved by the
Grok publisher.
+Let's first define a ``@@contents.html`` that is protected by a Zope
+permission, ``zope.ManageContent``::
+
+ >>> from zope.publisher.browser import BrowserPage
+ >>> class Contents(BrowserPage):
+ ... def __init__(self, context, request):
+ ... self.context = context
+ ... self.request = request
+ ... def __call__(self):
+ ... return "Contents called"
+ >>> from zope import component
+ >>> from zope.interface import Interface
+ >>> from zope.publisher.interfaces.browser import IBrowserRequest
+ >>> component.provideAdapter(Contents,
+ ... adapts=(Interface, IBrowserRequest),
+ ... provides=Interface,
+ ... name='contents.html')
+ >>> from zope.security.checker import Checker, defineChecker
+ >>> required = {}
+ >>> required['__call__'] = 'zope.ManageContent'
+ >>> required['browserDefault'] = 'zope.ManageContent'
+ >>> defineChecker(Contents, Checker(required))
+
The `@@contents.html` view of folders is protected by
`zope.ManageContent` and should not be visible to unauthenticated
users. Instead we are asked to authenticate ourselves::
@@ -10,40 +33,23 @@
>>> print http(r'''
... GET /@@contents.html HTTP/1.1
... ''')
- HTTP/1.1 401 Unauthorized
+ HTTP/1.0 401 Unauthorized
...
- WWW-Authenticate: basic realm="Zope"
- ...
-This is also the case for views on the Grok application object::
+Let's test this in the context of a Grok application:
>>> grok.testing.grok(__name__)
>>> from grok.ftests.security.preserve_permissions import App
>>> root = getRootFolder()
>>> root['app'] = App()
- >>> print http(r'''
- ... GET /app/++etc++site HTTP/1.1
- ... ''')
- HTTP/1.1 401 Unauthorized
- ...
- WWW-Authenticate: basic realm="Zope"
- ...
-We can allow our application to be viewed by the Zope standard
-``contents.html`` view for site folders. For this we make it provide
-`ISiteManagementFolder`::
-
- >>> from zope.site.interfaces import ISiteManagementFolder
- >>> from zope.interface import alsoProvides
- >>> alsoProvides(root['app'], ISiteManagementFolder)
-
Now there is a ``contents.html`` view available for our application,
which is protected by default::
>>> print http(r'''
... GET /app/@@contents.html HTTP/1.1
... ''')
- HTTP/1.1 401 Unauthorized
+ HTTP/1.0 401 Unauthorized
...
However, if we make a grant, e.g. on the root object, we can access
@@ -57,12 +63,12 @@
>>> print http(r'''
... GET /@@contents.html HTTP/1.1
... ''')
- HTTP/1.1 200 Ok
+ HTTP/1.0 200 Ok
...
The default view is accessible::
- >>> from zope.testbrowser.testing import Browser
+ >>> from zope.app.wsgi.testlayer import Browser
>>> browser = Browser()
>>> browser.open('http://localhost/app')
>>> print browser.contents
Modified: grok/trunk/src/grok/ftests/security/roles.py
===================================================================
--- grok/trunk/src/grok/ftests/security/roles.py 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/src/grok/ftests/security/roles.py 2010-07-05 17:38:31 UTC (rev 114216)
@@ -2,7 +2,7 @@
Viewing a protected view with insufficient privileges will yield
Unauthorized:
- >>> from zope.testbrowser.testing import Browser
+ >>> from zope.app.wsgi.testlayer import Browser
>>> browser = Browser()
>>> browser.open("http://localhost/@@cavepainting")
Modified: grok/trunk/src/grok/ftests/security/security_view.py
===================================================================
--- grok/trunk/src/grok/ftests/security/security_view.py 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/src/grok/ftests/security/security_view.py 2010-07-05 17:38:31 UTC (rev 114216)
@@ -25,7 +25,7 @@
However, when we want to watch this view, we run into trouble::
- >>> from zope.testbrowser.testing import Browser
+ >>> from zope.app.wsgi.testlayer import Browser
>>> browser = Browser()
>>> browser.handleErrors = False
>>> browser.open('http://localhost/app/@@index')
Modified: grok/trunk/src/grok/ftests/test_grok_functional.py
===================================================================
--- grok/trunk/src/grok/ftests/test_grok_functional.py 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/src/grok/ftests/test_grok_functional.py 2010-07-05 17:38:31 UTC (rev 114216)
@@ -1,23 +1,13 @@
import re
-import unittest
+import unittest, doctest
import grok
-import os.path
from pkg_resources import resource_listdir
-from zope.testing import doctest, renormalizing
-from zope.app.testing.functional import (HTTPCaller, getRootFolder,
- FunctionalTestSetup, sync, ZCMLLayer)
+from zope.testing import renormalizing
+from zope.app.wsgi.testlayer import BrowserLayer, http
-ftesting_zcml = os.path.join(os.path.dirname(grok.__file__), 'ftesting.zcml')
-GrokFunctionalLayer = ZCMLLayer(ftesting_zcml, __name__, 'GrokFunctionalLayer',
- allow_teardown=True)
+FunctionalLayer = BrowserLayer(grok)
-def setUp(test):
- FunctionalTestSetup().setUp()
-
-def tearDown(test):
- FunctionalTestSetup().tearDown()
-
checker = renormalizing.RENormalizing([
# Accommodate to exception wrapping in newer versions of mechanize
(re.compile(r'httperror_seek_wrapper:', re.M), 'HTTPError:'),
@@ -40,7 +30,7 @@
if data is not None:
request_string += '\r\n'
request_string += data
- return HTTPCaller()(request_string, handle_errors=False)
+ return http(request_string, handle_errors=False)
def suiteFromPackage(name):
files = resource_listdir(__name__, name)
@@ -53,26 +43,26 @@
dottedname = 'grok.ftests.%s.%s' % (name, filename[:-3])
test = doctest.DocTestSuite(
- dottedname, setUp=setUp, tearDown=tearDown,
+ dottedname,
checker=checker,
- extraglobs=dict(http=HTTPCaller(),
- http_call=http_call,
- getRootFolder=getRootFolder,
- sync=sync),
+ extraglobs=dict(http_call=http_call,
+ http=http,
+ getRootFolder=FunctionalLayer.getRootFolder),
optionflags=(doctest.ELLIPSIS+
doctest.NORMALIZE_WHITESPACE+
- doctest.REPORT_NDIFF)
- )
- test.layer = GrokFunctionalLayer
+ doctest.REPORT_NDIFF))
+ test.layer = FunctionalLayer
suite.addTest(test)
return suite
def test_suite():
suite = unittest.TestSuite()
- for name in ['xmlrpc', 'traversal', 'form', 'url', 'security', 'rest',
- 'catalog', 'site', 'application', 'viewlet', 'json',
- 'lifecycle']:
+ for name in [
+ 'xmlrpc',
+ 'traversal', 'form', 'url', 'security', 'rest',
+ 'catalog', 'site', 'application', 'viewlet', 'json',
+ 'lifecycle']:
suite.addTest(suiteFromPackage(name))
return suite
Modified: grok/trunk/src/grok/ftests/traversal/containertraverse.py
===================================================================
--- grok/trunk/src/grok/ftests/traversal/containertraverse.py 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/src/grok/ftests/traversal/containertraverse.py 2010-07-05 17:38:31 UTC (rev 114216)
@@ -9,7 +9,7 @@
Let's first try to look up the special traversed item:
- >>> from zope.testbrowser.testing import Browser
+ >>> from zope.app.wsgi.testlayer import Browser
>>> browser = Browser()
>>> browser.handleErrors = False
>>> browser.open("http://localhost/herd/special")
Modified: grok/trunk/src/grok/ftests/traversal/containertraverser.py
===================================================================
--- grok/trunk/src/grok/ftests/traversal/containertraverser.py 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/src/grok/ftests/traversal/containertraverser.py 2010-07-05 17:38:31 UTC (rev 114216)
@@ -9,7 +9,7 @@
Let's first try to look up the special traversed item:
- >>> from zope.testbrowser.testing import Browser
+ >>> from zope.app.wsgi.testlayer import Browser
>>> browser = Browser()
>>> browser.handleErrors = False
>>> browser.open("http://localhost/herd/special")
Modified: grok/trunk/src/grok/ftests/traversal/items_before_views.py
===================================================================
--- grok/trunk/src/grok/ftests/traversal/items_before_views.py 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/src/grok/ftests/traversal/items_before_views.py 2010-07-05 17:38:31 UTC (rev 114216)
@@ -8,7 +8,7 @@
>>> herd['manfred'] = Mammoth('Manfred')
>>> herd['ellie'] = Mammoth('Ellie')
- >>> from zope.testbrowser.testing import Browser
+ >>> from zope.app.wsgi.testlayer import Browser
>>> browser = Browser()
>>> browser.handleErrors = False
Modified: grok/trunk/src/grok/ftests/traversal/modeltraverse.py
===================================================================
--- grok/trunk/src/grok/ftests/traversal/modeltraverse.py 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/src/grok/ftests/traversal/modeltraverse.py 2010-07-05 17:38:31 UTC (rev 114216)
@@ -4,7 +4,7 @@
>>> getRootFolder()["herd"] = Herd('The Big Mammoth Herd')
- >>> from zope.testbrowser.testing import Browser
+ >>> from zope.app.wsgi.testlayer import Browser
>>> browser = Browser()
>>> browser.handleErrors = False
>>> browser.open("http://localhost/herd/manfred")
Modified: grok/trunk/src/grok/ftests/traversal/traversableattr.py
===================================================================
--- grok/trunk/src/grok/ftests/traversal/traversableattr.py 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/src/grok/ftests/traversal/traversableattr.py 2010-07-05 17:38:31 UTC (rev 114216)
@@ -3,7 +3,7 @@
>>> getRootFolder()["traversefoo"] = Foo('foo')
- >>> from zope.testbrowser.testing import Browser
+ >>> from zope.app.wsgi.testlayer import Browser
>>> browser = Browser()
>>> browser.handleErrors = False
Modified: grok/trunk/src/grok/ftests/traversal/traverser.py
===================================================================
--- grok/trunk/src/grok/ftests/traversal/traverser.py 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/src/grok/ftests/traversal/traverser.py 2010-07-05 17:38:31 UTC (rev 114216)
@@ -4,7 +4,7 @@
>>> getRootFolder()["herd"] = Herd('The Big Mammoth Herd')
- >>> from zope.testbrowser.testing import Browser
+ >>> from zope.app.wsgi.testlayer import Browser
>>> browser = Browser()
>>> browser.handleErrors = False
>>> browser.open("http://localhost/herd/manfred")
Modified: grok/trunk/src/grok/ftests/traversal/traverser_sets_parent.py
===================================================================
--- grok/trunk/src/grok/ftests/traversal/traverser_sets_parent.py 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/src/grok/ftests/traversal/traverser_sets_parent.py 2010-07-05 17:38:31 UTC (rev 114216)
@@ -4,7 +4,7 @@
>>> getRootFolder()["herd"] = Herd('The Big Mammoth Herd')
- >>> from zope.testbrowser.testing import Browser
+ >>> from zope.app.wsgi.testlayer import Browser
>>> browser = Browser()
>>> browser.handleErrors = False
>>> browser.open("http://localhost/herd/manfred")
Modified: grok/trunk/src/grok/ftests/url/application.py
===================================================================
--- grok/trunk/src/grok/ftests/url/application.py 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/src/grok/ftests/url/application.py 2010-07-05 17:38:31 UTC (rev 114216)
@@ -7,7 +7,7 @@
Asking for the application_url on the cave returns the URL to the cave::
- >>> from zope.testbrowser.testing import Browser
+ >>> from zope.app.wsgi.testlayer import Browser
>>> browser = Browser()
>>> browser.handleErrors = False
>>> browser.open('http://localhost/cave')
Modified: grok/trunk/src/grok/ftests/viewlet/viewlet_security.py
===================================================================
--- grok/trunk/src/grok/ftests/viewlet/viewlet_security.py 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/src/grok/ftests/viewlet/viewlet_security.py 2010-07-05 17:38:31 UTC (rev 114216)
@@ -17,7 +17,7 @@
Traverse to the view on the model object. We get the viewlets
registered for the default layer, with the anybody permission::
- >>> from zope.testbrowser.testing import Browser
+ >>> from zope.app.wsgi.testlayer import Browser
>>> browser = Browser()
>>> browser.handleErrors = False
>>> browser.open("http://localhost/wilma/@@caveview")
Modified: grok/trunk/src/grok/ftests/xmlrpc/require.py
===================================================================
--- grok/trunk/src/grok/ftests/xmlrpc/require.py 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/src/grok/ftests/xmlrpc/require.py 2010-07-05 17:38:31 UTC (rev 114216)
@@ -1,7 +1,7 @@
"""
- >>> from zope.app.testing.xmlrpc import ServerProxy
- >>> server = ServerProxy("http://localhost/")
- >>> mgr_server = ServerProxy("http://mgr:mgrpw@localhost/")
+ >>> from zope.app.wsgi.testlayer import XMLRPCServerProxy
+ >>> server = XMLRPCServerProxy("http://localhost/")
+ >>> mgr_server = XMLRPCServerProxy("http://mgr:mgrpw@localhost/")
We can access a public method just fine, but a protected method will
raise Unauthorized:
Modified: grok/trunk/src/grok/ftests/xmlrpc/xmlrpc.py
===================================================================
--- grok/trunk/src/grok/ftests/xmlrpc/xmlrpc.py 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/src/grok/ftests/xmlrpc/xmlrpc.py 2010-07-05 17:38:31 UTC (rev 114216)
@@ -1,8 +1,8 @@
"""
>>> getRootFolder()["Manfred"] = Mammoth()
- >>> from zope.app.testing.xmlrpc import ServerProxy
- >>> server = ServerProxy("http://localhost/")
+ >>> from zope.app.wsgi.testlayer import XMLRPCServerProxy
+ >>> server = XMLRPCServerProxy("http://localhost/")
>>> server.Manfred.stomp()
'Manfred stomped.'
Modified: grok/trunk/src/grok/meta.py
===================================================================
--- grok/trunk/src/grok/meta.py 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/src/grok/meta.py 2010-07-05 17:38:31 UTC (rev 114216)
@@ -32,14 +32,13 @@
from zope.securitypolicy.interfaces import IRole
from zope.securitypolicy.rolepermission import rolePermissionManager
-from zope.app.publisher.xmlrpc import MethodPublisher
-
from zope.intid import IntIds
from zope.intid.interfaces import IIntIds
from zope.catalog.catalog import Catalog
from zope.catalog.interfaces import ICatalog
-
+from zope.location import Location
from zope.exceptions.interfaces import DuplicationError
+from zope.publisher.xmlrpc import XMLRPCView
import martian
from martian.error import GrokError
@@ -54,7 +53,17 @@
from grokcore.view.meta.views import default_fallback_to_name
+class MethodPublisher(XMLRPCView, Location):
+ """Copied from zope.app.publisher.xmlrpc to get rid of that dependency.
+ """
+ def __getParent(self):
+ return hasattr(self, '_parent') and self._parent or self.context
+ def __setParent(self, parent):
+ self._parent = parent
+
+ __parent__ = property(__getParent, __setParent)
+
class XMLRPCGrokker(martian.MethodGrokker):
"""Grokker for methods of a `grok.XMLRPC` subclass.
Modified: grok/trunk/src/grok/testing.py
===================================================================
--- grok/trunk/src/grok/testing.py 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/src/grok/testing.py 2010-07-05 17:38:31 UTC (rev 114216)
@@ -14,31 +14,11 @@
"""Grok test helpers
"""
import sys
-import os.path
-import z3c.testsetup
from zope.configuration.config import ConfigurationMachine
from grokcore.component import zcml
# Provide this import here for BBB reasons:
from grokcore.component.testing import grok_component
-class GrokTestCollector(z3c.testsetup.TestCollector):
-
- def initialize(self):
- # inject the grok ftesting ZCML as fallback...
- if 'zcml_config' in self.settings.keys():
- return
- pkg_path = os.path.dirname(self.package.__file__)
- if os.path.isfile(os.path.join(pkg_path, 'ftesting.zcml')):
- return
- self.settings['zcml_config'] = os.path.join(
- os.path.dirname(__file__), 'ftesting.zcml')
- if 'layer_name' in self.settings.keys():
- return
- self.settings['layer_name'] = 'GrokFunctionalLayer'
-
-def register_all_tests(pkg, *args, **kw):
- return GrokTestCollector(pkg, *args, **kw)
-
def grok(module_name):
config = ConfigurationMachine()
zcml.do_grok('grokcore.component.meta', config)
Modified: grok/trunk/src/grok/tests/test_grok.py
===================================================================
--- grok/trunk/src/grok/tests/test_grok.py 2010-07-05 16:55:57 UTC (rev 114215)
+++ grok/trunk/src/grok/tests/test_grok.py 2010-07-05 17:38:31 UTC (rev 114216)
@@ -46,7 +46,8 @@
'zcml', 'utility', 'xmlrpc', 'json', 'container',
'traversal', 'grokker', 'directive',
'baseclass', 'application',
- 'viewlet', 'testsetup', 'conflict']:
+ 'viewlet',
+ 'conflict']:
suite.addTest(suiteFromPackage(name))
return suite
More information about the checkins
mailing list