Skip to content

Commit

Permalink
Remove zope.app.testing dependency and use zope.app.wsgi testing capa…
Browse files Browse the repository at this point in the history
…bitlities instead.
  • Loading branch information
thefunny42 committed Apr 14, 2010
1 parent 1de9361 commit 503b444
Show file tree
Hide file tree
Showing 19 changed files with 27 additions and 41 deletions.
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ def read(*rnames):
)

tests_require = [
'zope.app.testing',
'zope.app.wsgi',
'zope.configuration',
'zope.testbrowser',
'zope.testing',
]

Expand Down Expand Up @@ -91,7 +90,6 @@ def read(*rnames):
'zope.app.appsetup',
'zope.app.pagetemplate',
'zope.app.security',
'zope.app.twisted',
'zope.deprecation',
'zope.dottedname',
'zope.hookable',
Expand Down
2 changes: 1 addition & 1 deletion src/grok/ftests/catalog/addform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/grok/ftests/form/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion src/grok/ftests/security/grok_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion src/grok/ftests/security/handle_exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/grok/ftests/security/json.py
Original file line number Diff line number Diff line change
@@ -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::
Expand Down
2 changes: 1 addition & 1 deletion src/grok/ftests/security/preserve_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion src/grok/ftests/security/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion src/grok/ftests/security/security_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
30 changes: 9 additions & 21 deletions src/grok/ftests/test_grok_functional.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
import re
import unittest
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.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)

def setUp(test):
FunctionalTestSetup().setUp()

def tearDown(test):
FunctionalTestSetup().tearDown()
FunctionalLayer = BrowserLayer(grok)

checker = renormalizing.RENormalizing([
# Accommodate to exception wrapping in newer versions of mechanize
Expand All @@ -40,7 +30,7 @@ def http_call(method, path, data=None, **kw):
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)
Expand All @@ -53,17 +43,15 @@ def suiteFromPackage(name):

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
Expand Down
2 changes: 1 addition & 1 deletion src/grok/ftests/traversal/containertraverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion src/grok/ftests/traversal/containertraverser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion src/grok/ftests/traversal/items_before_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/grok/ftests/traversal/modeltraverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion src/grok/ftests/traversal/traversableattr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/grok/ftests/traversal/traverser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion src/grok/ftests/traversal/traverser_sets_parent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion src/grok/ftests/url/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion src/grok/ftests/viewlet/viewlet_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 503b444

Please sign in to comment.