summaryrefslogtreecommitdiff
path: root/tests/test_tweens.py
diff options
context:
space:
mode:
authorMichael Merickel <michael@merickel.org>2018-10-15 01:55:54 -0500
committerMichael Merickel <michael@merickel.org>2018-10-15 09:24:07 -0500
commit0c29cf2df41600d3906d521c72991c7686018b71 (patch)
treeff907f90ec9467e12874c9b2c961549d0e7caf74 /tests/test_tweens.py
parent851c368e3c158e264358de10446f5b5de240e534 (diff)
downloadpyramid-0c29cf2df41600d3906d521c72991c7686018b71.tar.gz
pyramid-0c29cf2df41600d3906d521c72991c7686018b71.tar.bz2
pyramid-0c29cf2df41600d3906d521c72991c7686018b71.zip
format source using black
Diffstat (limited to 'tests/test_tweens.py')
-rw-r--r--tests/test_tweens.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/test_tweens.py b/tests/test_tweens.py
index 2e74ad7cf..ab9b8b0cd 100644
--- a/tests/test_tweens.py
+++ b/tests/test_tweens.py
@@ -1,6 +1,7 @@
import unittest
from pyramid import testing
+
class Test_excview_tween_factory(unittest.TestCase):
def setUp(self):
self.config = testing.setUp()
@@ -10,14 +11,17 @@ class Test_excview_tween_factory(unittest.TestCase):
def _makeOne(self, handler, registry=None):
from pyramid.tweens import excview_tween_factory
+
if registry is None:
registry = self.config.registry
return excview_tween_factory(handler, registry)
def test_it_passthrough_no_exception(self):
dummy_response = DummyResponse()
+
def handler(request):
return dummy_response
+
tween = self._makeOne(handler)
request = DummyRequest()
result = tween(request)
@@ -28,9 +32,12 @@ class Test_excview_tween_factory(unittest.TestCase):
def test_it_catches_notfound(self):
from pyramid.request import Request
from pyramid.httpexceptions import HTTPNotFound
+
self.config.add_notfound_view(lambda exc, request: exc)
+
def handler(request):
raise HTTPNotFound
+
tween = self._makeOne(handler)
request = Request.blank('/')
request.registry = self.config.registry
@@ -42,11 +49,15 @@ class Test_excview_tween_factory(unittest.TestCase):
def test_it_catches_with_predicate(self):
from pyramid.request import Request
from pyramid.response import Response
+
def excview(request):
return Response('foo')
+
self.config.add_view(excview, context=ValueError, request_method='GET')
+
def handler(request):
raise ValueError
+
tween = self._makeOne(handler)
request = Request.blank('/')
request.registry = self.config.registry
@@ -57,10 +68,15 @@ class Test_excview_tween_factory(unittest.TestCase):
def test_it_reraises_on_mismatch(self):
from pyramid.request import Request
- def excview(request): pass
+
+ def excview(request):
+ pass
+
self.config.add_view(excview, context=ValueError, request_method='GET')
+
def handler(request):
raise ValueError
+
tween = self._makeOne(handler)
request = Request.blank('/')
request.registry = self.config.registry
@@ -71,8 +87,10 @@ class Test_excview_tween_factory(unittest.TestCase):
def test_it_reraises_on_no_match(self):
from pyramid.request import Request
+
def handler(request):
raise ValueError
+
tween = self._makeOne(handler)
request = Request.blank('/')
request.registry = self.config.registry
@@ -80,9 +98,11 @@ class Test_excview_tween_factory(unittest.TestCase):
self.assertIsNone(request.exception)
self.assertIsNone(request.exc_info)
+
class DummyRequest:
exception = None
exc_info = None
+
class DummyResponse:
pass