diff options
| author | Michael Merickel <michael@merickel.org> | 2014-04-23 15:15:58 -0500 |
|---|---|---|
| committer | Michael Merickel <michael@merickel.org> | 2014-04-23 15:15:58 -0500 |
| commit | 75d871ce118456eeaa2fac7136faf0ff4478dd89 (patch) | |
| tree | 548929f925379b1f16fdb8b31a915eee7e089caa | |
| parent | b13a78db3350cadf77183cac0a71860804fdde75 (diff) | |
| parent | 2eb28f583cc423ab2c6b9b830cf40da7795ca04a (diff) | |
| download | pyramid-75d871ce118456eeaa2fac7136faf0ff4478dd89.tar.gz pyramid-75d871ce118456eeaa2fac7136faf0ff4478dd89.tar.bz2 pyramid-75d871ce118456eeaa2fac7136faf0ff4478dd89.zip | |
Merge pull request #1320 from bertjwregeer/feature.raise_valueerror_wsgi
Feature: raise ValueError if wrapped is None in wsgiapp/wsgiapp2
| -rw-r--r-- | CHANGES.txt | 2 | ||||
| -rw-r--r-- | pyramid/tests/test_wsgi.py | 22 | ||||
| -rw-r--r-- | pyramid/wsgi.py | 7 |
3 files changed, 31 insertions, 0 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index b0495617b..2761c29dc 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -10,6 +10,8 @@ Next release introspectable but not when passed for registration. This would mean that add_route_predicate for example can not take a string and turn it into the actual callable function. +- p.wsgi.wsgiapp and p.wsgi.wsgiapp2 now raise ValueError when accidentally + passed None. 1.5 (2014-04-08) ================ diff --git a/pyramid/tests/test_wsgi.py b/pyramid/tests/test_wsgi.py index 63499b43b..432fb72ae 100644 --- a/pyramid/tests/test_wsgi.py +++ b/pyramid/tests/test_wsgi.py @@ -5,6 +5,17 @@ class WSGIAppTests(unittest.TestCase): from pyramid.wsgi import wsgiapp return wsgiapp(app) + def test_wsgiapp_none(self): + self.assertRaises(ValueError, self._callFUT, None) + + def test_wsgiapp_none_func(self): + from pyramid.wsgi import wsgiapp + + def some_func(): + pass + + self.assertRaises(ValueError, wsgiapp, some_func()) + def test_decorator(self): context = DummyContext() request = DummyRequest() @@ -25,6 +36,17 @@ class WSGIApp2Tests(unittest.TestCase): from pyramid.wsgi import wsgiapp2 return wsgiapp2(app) + def test_wsgiapp2_none(self): + self.assertRaises(ValueError, self._callFUT, None) + + def test_wsgiapp2_none_func(self): + from pyramid.wsgi import wsgiapp2 + + def some_func(): + pass + + self.assertRaises(ValueError, wsgiapp2, some_func()) + def test_decorator_with_subpath_and_view_name(self): context = DummyContext() request = DummyRequest() diff --git a/pyramid/wsgi.py b/pyramid/wsgi.py index d176e4ce5..1c1bded32 100644 --- a/pyramid/wsgi.py +++ b/pyramid/wsgi.py @@ -29,6 +29,10 @@ def wsgiapp(wrapped): view. """ + + if wrapped is None: + raise ValueError('wrapped can not be None') + def decorator(context, request): return request.get_response(wrapped) @@ -69,6 +73,9 @@ def wsgiapp2(wrapped): subpath is used as the ``SCRIPT_NAME``. The new environment is passed to the downstream WSGI application.""" + if wrapped is None: + raise ValueError('wrapped can not be None') + def decorator(context, request): return call_app_with_subpath_as_path_info(request, wrapped) |
