diff options
| author | Chris McDonough <chrism@plope.com> | 2011-11-08 17:04:08 -0800 |
|---|---|---|
| committer | Chris McDonough <chrism@plope.com> | 2011-11-08 17:04:08 -0800 |
| commit | 9da33516637075b5a41b2e8bf500297a4cb71166 (patch) | |
| tree | f9381870d261fa41732f549bed534231cad4013c | |
| parent | a3ff61a5a554973e4c84c2120f0c6c019e192d9e (diff) | |
| parent | dfbbe87219e848ea6f02a94926140d918beb088d (diff) | |
| download | pyramid-9da33516637075b5a41b2e8bf500297a4cb71166.tar.gz pyramid-9da33516637075b5a41b2e8bf500297a4cb71166.tar.bz2 pyramid-9da33516637075b5a41b2e8bf500297a4cb71166.zip | |
Merge branch 'RichardBarrell-issue330'
| -rw-r--r-- | pyramid/httpexceptions.py | 2 | ||||
| -rw-r--r-- | pyramid/tests/test_httpexceptions.py | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/pyramid/httpexceptions.py b/pyramid/httpexceptions.py index 4dbca7021..bd745df87 100644 --- a/pyramid/httpexceptions.py +++ b/pyramid/httpexceptions.py @@ -434,6 +434,8 @@ ${html_comment}''') def __init__(self, location='', detail=None, headers=None, comment=None, body_template=None, **kw): + if location is None: + raise ValueError("HTTP redirects need a location to redirect to.") super(_HTTPMove, self).__init__( detail=detail, headers=headers, comment=comment, body_template=body_template, location=location, **kw) diff --git a/pyramid/tests/test_httpexceptions.py b/pyramid/tests/test_httpexceptions.py index 927d27733..84485fadc 100644 --- a/pyramid/tests/test_httpexceptions.py +++ b/pyramid/tests/test_httpexceptions.py @@ -294,6 +294,12 @@ class Test_HTTPMove(unittest.TestCase): from pyramid.httpexceptions import _HTTPMove return _HTTPMove(*arg, **kw) + def test_it_location_none_valueerrors(self): + # Constructing a HTTPMove instance with location=None should + # throw a ValueError from __init__ so that a more-confusing + # exception won't be thrown later from .prepare(environ) + self.assertRaises(ValueError, self._makeOne, location=None) + def test_it_location_not_passed(self): exc = self._makeOne() self.assertEqual(exc.location, '') |
