Skip to content

Commit

Permalink
Use zExceptions 3.5 release, add tests and fix the implementation.
Browse files Browse the repository at this point in the history
The `raise exc` vs. `raise` change got lost from the last attempt.
  • Loading branch information
hannosch committed Feb 5, 2017
1 parent 1f6d503 commit 789882f
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Features Added
- WebOb = 1.7.1
- WebTest = 2.0.24
- zdaemon = 4.2.0
- zExceptions = 3.5
- zope.deprecation = 4.2.0
- zope.interface = 4.3.3
- zope.testbrowser = 5.0
Expand Down
1 change: 0 additions & 1 deletion buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ parts =
requirements
sources-dir = develop
auto-checkout =
zExceptions


[test]
Expand Down
2 changes: 1 addition & 1 deletion requirements-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ sourcecodegen==0.6.14
transaction==1.6.1
waitress==1.0.1
z3c.pt==3.0
zExceptions==3.4
zExceptions==3.5
zc.lockfile==1.2.1
zdaemon==4.2.0
zodbpickle==0.6.0
Expand Down
2 changes: 1 addition & 1 deletion sources.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ five.globalrequest = git ${remotes:github}/five.globalrequest pushurl=${remotes:
MultiMapping = git ${remotes:github}/MultiMapping pushurl=${remotes:github_push}/MultiMapping
Persistence = git ${remotes:github}/Persistence pushurl=${remotes:github_push}/Persistence
RestrictedPython = git ${remotes:github}/RestrictedPython pushurl=${remotes:github_push}/RestrictedPython
zExceptions = git ${remotes:github}/zExceptions pushurl=${remotes:github_push}/zExceptions branch=davisagli-upgradeException
zExceptions = git ${remotes:github}/zExceptions pushurl=${remotes:github_push}/zExceptions
zope.globalrequest = git ${remotes:github}/zope.globalrequest pushurl=${remotes:github_push}/zope.globalrequest

# Optional dependencies
Expand Down
2 changes: 1 addition & 1 deletion src/ZPublisher/WSGIPublisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def _publish_response(request, response, module_info, _publish=publish):
if isinstance(exc, (HTTPRedirection, Unauthorized)):
return response

raise
raise exc

return response

Expand Down
26 changes: 26 additions & 0 deletions src/ZPublisher/tests/test_WSGIPublisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,20 @@ def test_swallows_Redirect(self):
self.assertTrue(('Content-Length', '0') in headers)
self.assertEqual(kw, {})

def test_upgrades_ztk_not_found(self):
from zExceptions import NotFound
from zope.publisher.interfaces import NotFound as ZTK_NotFound
environ = self._makeEnviron()
start_response = DummyCallable()
_publish = DummyCallable()
_publish._raise = ZTK_NotFound(object(), 'name_not_found')
try:
self._callFUT(environ, start_response, _publish)
except ZTK_NotFound:
self.fail('ZTK exception raised, expected zExceptions.')
except NotFound as exc:
self.assertTrue('name_not_found' in str(exc))

def test_response_body_is_file(self):
from io import BytesIO

Expand Down Expand Up @@ -453,6 +467,18 @@ def testCustomExceptionViewNotFound(self):
self.assertEqual(start_response._called_with[0][0], '404 Not Found')
self.assertTrue('Exception View: NotFound' in body)

def testCustomExceptionViewZTKNotFound(self):
from zope.publisher.interfaces import NotFound as ZTK_NotFound
registerExceptionView(INotFound)
environ = self._makeEnviron()
start_response = DummyCallable()
_publish = DummyCallable()
_publish._raise = ZTK_NotFound(object(), 'argh')
app_iter = self._callFUT(environ, start_response, _publish)
body = ''.join(app_iter)
self.assertEqual(start_response._called_with[0][0], '404 Not Found')
self.assertTrue('Exception View: NotFound' in body)

def testCustomExceptionViewBadRequest(self):
from zExceptions import BadRequest
registerExceptionView(IException)
Expand Down
2 changes: 1 addition & 1 deletion versions-prod.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ zc.lockfile = 1.2.1
ZConfig = 3.1.0
zdaemon = 4.2.0
ZEO = 5.0.1
zExceptions = 3.4
zExceptions = 3.5
ZODB = 5.0.0
zodbpickle = 0.6.0
zope.annotation = 4.4.1
Expand Down

0 comments on commit 789882f

Please sign in to comment.