Skip to content

Commit

Permalink
Fix tests for Python 3.5 and claim compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
sallner committed Jul 11, 2016
1 parent b0deab7 commit 3dd659e
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 20 deletions.
2 changes: 2 additions & 0 deletions setup.py
Expand Up @@ -60,6 +60,8 @@ def read(*rnames):
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Natural Language :: English',
'Operating System :: OS Independent',
'Topic :: Internet :: WWW/HTTP',
Expand Down
12 changes: 6 additions & 6 deletions src/zope/app/publication/httpfactory.txt
Expand Up @@ -14,21 +14,21 @@ A regular GET, POST or HEAD

>>> from zope.app.wsgi.testlayer import http

>>> print(http(b"""\
>>> print(http(wsgi_app, b"""\
... GET / HTTP/1.1
... """))
HTTP/1.0 200 OK
Content-Length: ...
Content-Type: text/html;charset=utf-8
...
>>> print(http(b"""\
>>> print(http(wsgi_app, b"""\
... POST / HTTP/1.1
... """))
HTTP/1.0 200 OK
Content-Length: ...
Content-Type: text/html;charset=utf-8
...
>>> print(http(b"""\
>>> print(http(wsgi_app, b"""\
... HEAD / HTTP/1.1
... """))
HTTP/1.0 200 OK
Expand All @@ -38,7 +38,7 @@ A regular GET, POST or HEAD

A text/xml POST request, wich is an xml-rpc call

>>> print(http(b"""\
>>> print(http(wsgi_app, b"""\
... POST /RPC2 HTTP/1.0
... Content-Type: text/xml
... """))
Expand All @@ -52,7 +52,7 @@ wich is an xml-rpc call:

TODO need to create a real SOAP exchange test here

>>> print(http(b"""\
>>> print(http(wsgi_app, b"""\
... POST /RPC2 HTTP/1.0
... Content-Type: text/xml
... HTTP_SOAPACTION: soap#action
Expand All @@ -66,7 +66,7 @@ Unknown request types:

TODO need more testing here

>>> print(http(b"""\
>>> print(http(wsgi_app, b"""\
... POST /BUBA HTTP/1.0
... Content-Type: text/topnotch
... """))
Expand Down
10 changes: 5 additions & 5 deletions src/zope/app/publication/methodnotallowed.txt
Expand Up @@ -8,23 +8,23 @@ view, HTTP 405 Method Not Allowed response is returned:

>>> from zope.app.wsgi.testlayer import http

>>> print(http(b"""\
>>> print(http(wsgi_app, b"""\
... FROG / HTTP/1.1
... """))
HTTP/1.0 405 Method Not Allowed
Allow: DELETE, OPTIONS, PUT
Content-Length: 18
...

>>> print(http(b"""\
>>> print(http(wsgi_app, b"""\
... DELETE / HTTP/1.1
... """))
HTTP/1.0 405 Method Not Allowed
...

Trying to PUT on an object which does not support PUT leads to 405:

>>> print(http(b"""\
>>> print(http(wsgi_app, b"""\
... PUT / HTTP/1.1
... Authorization: Basic mgr:mgrpw
... """))
Expand All @@ -34,7 +34,7 @@ Trying to PUT on an object which does not support PUT leads to 405:
Trying to PUT a not existing object on a container which does not support
PUT leads to 405:

>>> print(http(b"""\
>>> print(http(wsgi_app, b"""\
... PUT /asdf HTTP/1.1
... Authorization: Basic mgr:mgrpw
... """))
Expand All @@ -43,7 +43,7 @@ PUT leads to 405:

When ``handle_errors`` is set to ``False`` a traceback is displayed:

>>> print(http(b"""\
>>> print(http(wsgi_app, b"""\
... PUT / HTTP/1.1
... Authorization: Basic mgr:mgrpw
... """, handle_errors=False))
Expand Down
2 changes: 1 addition & 1 deletion src/zope/app/publication/notfound.txt
Expand Up @@ -7,7 +7,7 @@ to an object that doesn't exist, as in:
>>> from __future__ import print_function

>>> from zope.app.wsgi.testlayer import http
>>> print(http(b"""\
>>> print(http(wsgi_app, b"""\
... GET /eek HTTP/1.1
... """))
HTTP/1.0 404 Not Found
Expand Down
3 changes: 2 additions & 1 deletion src/zope/app/publication/testing.py
Expand Up @@ -29,4 +29,5 @@ def __call__(self):
return "<html><body>Test</body></html>"


PublicationLayer = BrowserLayer(zope.app.publication, name='PublicationLayer')
PublicationLayer = BrowserLayer(
zope.app.publication, name='PublicationLayer', allowTearDown=True)
12 changes: 8 additions & 4 deletions src/zope/app/publication/tests/test_functional.py
Expand Up @@ -32,17 +32,22 @@

optionflags = doctest.ELLIPSIS+doctest.NORMALIZE_WHITESPACE


def setUpTestLayer(test):
test.globs['wsgi_app'] = PublicationLayer.make_wsgi_app()


def test_suite():
methodnotallowed = doctest.DocFileSuite(
'../methodnotallowed.txt',
'../methodnotallowed.txt', setUp=setUpTestLayer,
optionflags=optionflags, checker=excchecker)
methodnotallowed.layer = PublicationLayer
notfound = doctest.DocFileSuite(
'../notfound.txt',
'../notfound.txt', setUp=setUpTestLayer,
optionflags=optionflags)
notfound.layer = PublicationLayer
httpfactory = doctest.DocFileSuite(
'../httpfactory.txt', checker=checker,
'../httpfactory.txt', checker=checker, setUp=setUpTestLayer,
optionflags=optionflags)
httpfactory.layer = PublicationLayer
site = doctest.DocFileSuite(
Expand All @@ -57,4 +62,3 @@ def test_suite():

if __name__ == '__main__':
unittest.main(defaultTest='test_suite')

8 changes: 5 additions & 3 deletions src/zope/app/publication/tests/test_zopepublication.py
Expand Up @@ -249,7 +249,7 @@ def testRetryNotAllowed(self):
value = ''.join(self.request.response._result).split()
self.assertEqual(' '.join(value[:6]),
'Traceback (most recent call last): File')
self.assertEqual(' '.join(value[-6:]),
self.assertIn(' '.join(value[-5:]),
'in testRetryNotAllowed raise Retry'
' %s: None' % excname)

Expand Down Expand Up @@ -418,9 +418,10 @@ def testExceptionResetsResponseTransientError(self):
try:
raise TransientError
except:
exec_info = sys.exc_info()
pass
self.publication.handleException(
self.object, request, sys.exc_info(), retry_allowed=False)
self.object, request, exec_info, retry_allowed=False)
self.assertEqual(request.response.getHeader('Content-Type'),
'text/html;charset=utf-8')
self.assertEqual(request.response._cookies, {})
Expand All @@ -434,9 +435,10 @@ def testExceptionResetsResponse(self):
try:
raise ConflictError
except:
exec_info = sys.exc_info()
pass
self.publication.handleException(
self.object, request, sys.exc_info(), retry_allowed=False)
self.object, request, exec_info, retry_allowed=False)
self.assertEqual(request.response.getHeader('Content-Type'),
'text/html;charset=utf-8')
self.assertEqual(request.response._cookies, {})
Expand Down

0 comments on commit 3dd659e

Please sign in to comment.