diff options
author | Jenkins <jenkins@review.openstack.org> | 2013-09-26 16:16:28 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2013-09-26 16:16:28 +0000 |
commit | 3831ba4ec1f10a8a564f9e6003f9de6d318cbd2a (patch) | |
tree | 21f2ae0f670ae337bd170da0cdc061ba75761319 | |
parent | 0db2a27641fee9fdf6aa0f2e629dc45b5db67ab7 (diff) | |
parent | 5d55e2a2d0e67d79d0ffeaab0866b10284deb1d7 (diff) | |
download | pecan-3831ba4ec1f10a8a564f9e6003f9de6d318cbd2a.tar.gz |
Merge "core: do not try to set response body to None"
-rw-r--r-- | pecan/core.py | 2 | ||||
-rw-r--r-- | pecan/tests/test_base.py | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/pecan/core.py b/pecan/core.py index 85ae5e6..8962f42 100644 --- a/pecan/core.py +++ b/pecan/core.py @@ -541,7 +541,7 @@ class Pecan(object): # set the body content if isinstance(result, six.text_type): resp.text = result - else: + elif result: resp.body = result # set the content type diff --git a/pecan/tests/test_base.py b/pecan/tests/test_base.py index e5ec6af..d9808a0 100644 --- a/pecan/tests/test_base.py +++ b/pecan/tests/test_base.py @@ -33,6 +33,23 @@ class TestAppRoot(PecanTestCase): assert app.root and isinstance(app.root, SampleRootController) +class TestEmptyContent(PecanTestCase): + @property + def app_(self): + class RootController(object): + @expose() + def index(self): + pass + + return TestApp(Pecan(RootController())) + + def test_empty_index(self): + r = self.app_.get('/') + self.assertEqual(r.status_int, 200) + self.assertEqual(r.headers['Content-Length'], '0') + self.assertEqual(len(r.body), 0) + + class TestIndexRouting(PecanTestCase): @property |