Mercurial > p > roundup > code
diff test/test_cgi.py @ 6382:b35a50d02890
Fix issue2551129 - Template not found return 500 and traceback
Handle traceback caused when requested @template is not found.
Moved scope of try to include call to self.selectTemplate.
Patch provided by Cedric Krier.
Additional patch to make this case return 400 error since it
is a client caused error. Test case added.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sun, 18 Apr 2021 20:54:48 -0400 |
| parents | f2c31f5ec50b |
| children | ada96db8ec62 |
line wrap: on
line diff
--- a/test/test_cgi.py Sun Apr 18 19:28:12 2021 -0400 +++ b/test/test_cgi.py Sun Apr 18 20:54:48 2021 -0400 @@ -746,6 +746,17 @@ 'name': 'foo.txt', 'type': 'text/plain'}}, [('issue', None, 'files', [('file', '-1')])])) + def testErrorForBadTemplate(self): + form = {} + cl = self.setupClient(form, 'issue', '1', template="broken", + env_addon = {'HTTP_REFERER': 'http://whoami.com/path/'}) + out = [] + + out = cl.renderContext() + + self.assertEqual(out, '<strong>No template file exists for templating "issue" with template "broken" (neither "issue.broken" nor "_generic.broken")</strong>') + self.assertEqual(cl.response_code, 400) + def testFormValuePreserveOnError(self): page_template = """ <html>
