summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan Crooks <allan@amcone.net>2014-04-15 17:00:51 -0400
committerAllan Crooks <allan@amcone.net>2014-04-15 17:00:51 -0400
commit2210cfadff4b59b673f8762bd2561b4d3a3558fa (patch)
tree579000e8764b2333fdea236c4c6b8c2c2e99e10a
parentbb2ef7bd5efda54bd45de276a4006bbd95d5598d (diff)
downloadcherrypy-git-2210cfadff4b59b673f8762bd2561b4d3a3558fa.tar.gz
Added failing test showing problems using error_page handlers and serve_file. Taken from submitted ticket in #1288.
-rw-r--r--cherrypy/test/test_static.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/cherrypy/test/test_static.py b/cherrypy/test/test_static.py
index a64fa586..de86d0bf 100644
--- a/cherrypy/test/test_static.py
+++ b/cherrypy/test/test_static.py
@@ -80,6 +80,12 @@ class StaticTest(helper.CPWebCase):
'tools.staticdir.on': True,
'request.show_tracebacks': True,
},
+ '/404test': {
+ 'tools.staticdir.on': True,
+ 'tools.staticdir.root': curdir,
+ 'tools.staticdir.dir': 'static',
+ 'error_page.404': error_page_404,
+ }
}
rootApp = cherrypy.Application(root)
rootApp.merge(rootconf)
@@ -301,3 +307,13 @@ class StaticTest(helper.CPWebCase):
if self.body != ntob("x" * BIGFILE_SIZE):
self.fail("Body != 'x' * %d. Got %r instead (%d bytes)." %
(BIGFILE_SIZE, self.body[:50], len(body)))
+
+ def test_error_page_with_serve_file(self):
+ self.getPage("/404test/yunyeen")
+ self.assertStatus(404)
+ self.assertInBody("I couldn't find that thing")
+
+def error_page_404(status, message, traceback, version):
+ import os.path
+ return static.serve_file(os.path.join(curdir, 'static', '404.html'),
+ content_type='text/html')