Controllers that return `None` should be an HTTP 204.
This commit is contained in:
parent
53eeda946d
commit
fbcc2c27f7
|
@ -417,6 +417,8 @@ class PecanBase(object):
|
|||
self.default_renderer,
|
||||
self.template_path
|
||||
)
|
||||
if namespace is None:
|
||||
return None
|
||||
return renderer.render(template, namespace)
|
||||
|
||||
def find_controller(self, state):
|
||||
|
|
|
@ -2001,6 +2001,29 @@ class TestEngines(PecanTestCase):
|
|||
assert r.status_int == 200
|
||||
assert r.body == b_("Bill")
|
||||
|
||||
def test_template_with_no_namespace(self):
|
||||
class RootController(object):
|
||||
@expose('mako:mako.html')
|
||||
def index(self):
|
||||
return None
|
||||
|
||||
app = TestApp(Pecan(
|
||||
RootController(),
|
||||
template_path=self.template_path
|
||||
))
|
||||
r = app.get('/')
|
||||
self.assertEqual(r.status_int, 204)
|
||||
|
||||
def test_json_with_no_namespace(self):
|
||||
class RootController(object):
|
||||
@expose('json')
|
||||
def index(self):
|
||||
return None
|
||||
|
||||
app = TestApp(Pecan(RootController()))
|
||||
r = app.get('/')
|
||||
self.assertEqual(r.status_int, 204)
|
||||
|
||||
|
||||
class TestDeprecatedRouteMethod(PecanTestCase):
|
||||
|
||||
|
|
Loading…
Reference in New Issue