diff options
| author | Bert JW Regeer <bertjw@regeer.org> | 2014-04-22 20:00:53 -0600 |
|---|---|---|
| committer | Bert JW Regeer <bertjw@regeer.org> | 2014-04-22 20:05:14 -0600 |
| commit | d292b97587c19b4aa7fa0150a8b5ecc8d758b783 (patch) | |
| tree | d63caeb6a7fe232aaa37a42cc1666e60969f2136 | |
| parent | b13a78db3350cadf77183cac0a71860804fdde75 (diff) | |
| download | pyramid-d292b97587c19b4aa7fa0150a8b5ecc8d758b783.tar.gz pyramid-d292b97587c19b4aa7fa0150a8b5ecc8d758b783.tar.bz2 pyramid-d292b97587c19b4aa7fa0150a8b5ecc8d758b783.zip | |
Verify that wrapped is not None
If wrapped is None we raise a ValueError to let the user know that we
are unable to continue.
| -rw-r--r-- | pyramid/tests/test_wsgi.py | 22 | ||||
| -rw-r--r-- | pyramid/wsgi.py | 7 |
2 files changed, 29 insertions, 0 deletions
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) |
