From 2fd42e8c624777b80fcf10cde361a909c9b0ad64 Mon Sep 17 00:00:00 2001 From: Lee Kyoung chan Date: Sun, 14 Sep 2014 10:56:52 +0900 Subject: [PATCH] Added test_removeslash. --- tornado/test/web_test.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tornado/test/web_test.py b/tornado/test/web_test.py index 1a02718..85672d3 100644 --- a/tornado/test/web_test.py +++ b/tornado/test/web_test.py @@ -2357,3 +2357,29 @@ def test_finish_exception(self): self.assertEqual('Basic realm="something"', response.headers.get('WWW-Authenticate')) self.assertEqual(b'authentication required', response.body) + + +from tornado.web import removeslash, addslash +class DecoratorTest(WebTestCase): + def get_handlers(self): + class RemoveSlashHandler(RequestHandler): + @removeslash + def get(self): + pass + + class AddSlashHandler(RequestHandler): + @addslash + def get(self): + pass + + return [("/removeslash", RemoveSlashHandler), + ("/addslash", AddSlashHandler), + ] + + def test_removeslash(self): + self.http_client.fetch(self.get_url('/removeslash/'), self.stop, + follow_redirects=False) + response = self.wait() + self.assertEqual(response.code, 302) + self.assertEqual(response.headers['Location'], '/removeslash') +