From: Ben Darnell Date: Sun, 9 Sep 2012 20:23:49 +0000 (-0700) Subject: Suppress tornado.access logs in tests, and remove LogTrapTestCase X-Git-Tag: v3.0.0~272^2~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ba0b9d43834977de37f7f5b5207f31c2a2ca631c;p=thirdparty%2Ftornado.git Suppress tornado.access logs in tests, and remove LogTrapTestCase from tests that no longer produce any logs. --- diff --git a/tornado/test/auth_test.py b/tornado/test/auth_test.py index 916194d29..6459d4c1d 100644 --- a/tornado/test/auth_test.py +++ b/tornado/test/auth_test.py @@ -7,7 +7,7 @@ from __future__ import absolute_import, division, with_statement from tornado.auth import OpenIdMixin, OAuthMixin, OAuth2Mixin from tornado.escape import json_decode -from tornado.testing import AsyncHTTPTestCase, LogTrapTestCase +from tornado.testing import AsyncHTTPTestCase from tornado.util import b from tornado.web import RequestHandler, Application, asynchronous @@ -101,7 +101,7 @@ class OAuth2ClientLoginHandler(RequestHandler, OAuth2Mixin): self.authorize_redirect() -class AuthTest(AsyncHTTPTestCase, LogTrapTestCase): +class AuthTest(AsyncHTTPTestCase): def get_app(self): return Application( [ diff --git a/tornado/test/httpclient_test.py b/tornado/test/httpclient_test.py index f1ceed981..08afff085 100644 --- a/tornado/test/httpclient_test.py +++ b/tornado/test/httpclient_test.py @@ -11,7 +11,7 @@ from tornado.escape import utf8 from tornado.httpclient import AsyncHTTPClient from tornado.iostream import IOStream from tornado import netutil -from tornado.testing import AsyncHTTPTestCase, LogTrapTestCase, get_unused_port +from tornado.testing import AsyncHTTPTestCase, get_unused_port from tornado.util import b, bytes_type from tornado.web import Application, RequestHandler, url @@ -59,7 +59,7 @@ class EchoPostHandler(RequestHandler): # test suite. -class HTTPClientCommonTestCase(AsyncHTTPTestCase, LogTrapTestCase): +class HTTPClientCommonTestCase(AsyncHTTPTestCase): def get_app(self): return Application([ url("/hello", HelloWorldHandler), diff --git a/tornado/test/httpserver_test.py b/tornado/test/httpserver_test.py index 69af3a0ed..bb01843fd 100644 --- a/tornado/test/httpserver_test.py +++ b/tornado/test/httpserver_test.py @@ -25,7 +25,7 @@ except ImportError: ssl = None -class HandlerBaseTestCase(AsyncHTTPTestCase, LogTrapTestCase): +class HandlerBaseTestCase(AsyncHTTPTestCase): def get_app(self): return Application([('/', self.__class__.Handler)]) @@ -166,7 +166,7 @@ class RawRequestHTTPConnection(simple_httpclient._HTTPConnection): # This test is also called from wsgi_test -class HTTPConnectionTest(AsyncHTTPTestCase, LogTrapTestCase): +class HTTPConnectionTest(AsyncHTTPTestCase): def get_handlers(self): return [("/multipart", MultipartTestHandler), ("/hello", HelloWorldRequestHandler)] @@ -288,7 +288,7 @@ class TypeCheckHandler(RequestHandler): actual_type) -class HTTPServerTest(AsyncHTTPTestCase, LogTrapTestCase): +class HTTPServerTest(AsyncHTTPTestCase): def get_app(self): return Application([("/echo", EchoHandler), ("/typecheck", TypeCheckHandler), @@ -352,7 +352,7 @@ class XHeaderTest(HandlerBaseTestCase): "127.0.0.1") -class UnixSocketTest(AsyncTestCase, LogTrapTestCase): +class UnixSocketTest(AsyncTestCase): """HTTPServers can listen on Unix sockets too. Why would you want to do this? Nginx can proxy to backends listening diff --git a/tornado/test/ioloop_test.py b/tornado/test/ioloop_test.py index 4e5e123c9..63ef31f54 100644 --- a/tornado/test/ioloop_test.py +++ b/tornado/test/ioloop_test.py @@ -8,11 +8,11 @@ import time from tornado.ioloop import IOLoop from tornado.netutil import bind_sockets -from tornado.testing import AsyncTestCase, LogTrapTestCase, get_unused_port +from tornado.testing import AsyncTestCase, get_unused_port from tornado.test.util import unittest -class TestIOLoop(AsyncTestCase, LogTrapTestCase): +class TestIOLoop(AsyncTestCase): def test_add_callback_wakeup(self): # Make sure that add_callback from inside a running IOLoop # wakes up the IOLoop immediately instead of waiting for a timeout. diff --git a/tornado/test/runtests.py b/tornado/test/runtests.py index 13c03ce85..adf761db4 100644 --- a/tornado/test/runtests.py +++ b/tornado/test/runtests.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from __future__ import absolute_import, division, with_statement +import logging import textwrap import sys from tornado.test.util import unittest @@ -66,6 +67,8 @@ if __name__ == '__main__': warnings.filterwarnings("error", category=DeprecationWarning, module=r"tornado\..*") + logging.getLogger("tornado.access").setLevel(logging.CRITICAL) + import tornado.testing kwargs = {} if sys.version_info >= (3, 2): diff --git a/tornado/test/simple_httpclient_test.py b/tornado/test/simple_httpclient_test.py index 4ab018431..f84f7631f 100644 --- a/tornado/test/simple_httpclient_test.py +++ b/tornado/test/simple_httpclient_test.py @@ -299,7 +299,7 @@ class SimpleHTTPClientTestCase(AsyncHTTPTestCase, LogTrapTestCase): response.error) -class CreateAsyncHTTPClientTestCase(AsyncTestCase, LogTrapTestCase): +class CreateAsyncHTTPClientTestCase(AsyncTestCase): def setUp(self): super(CreateAsyncHTTPClientTestCase, self).setUp() self.saved = AsyncHTTPClient._save_configuration() @@ -336,7 +336,7 @@ class CreateAsyncHTTPClientTestCase(AsyncTestCase, LogTrapTestCase): self.assertEqual(client.max_clients, 14) -class HTTP100ContinueTestCase(AsyncHTTPTestCase, LogTrapTestCase): +class HTTP100ContinueTestCase(AsyncHTTPTestCase): def respond_100(self, request): self.request = request self.request.connection.stream.write( diff --git a/tornado/test/template_test.py b/tornado/test/template_test.py index 6e14abb92..793b1bbb4 100644 --- a/tornado/test/template_test.py +++ b/tornado/test/template_test.py @@ -6,10 +6,11 @@ import traceback from tornado.escape import utf8, native_str, to_unicode from tornado.template import Template, DictLoader, ParseError, Loader from tornado.testing import LogTrapTestCase +from tornado.test.util import unittest from tornado.util import b, bytes_type, ObjectDict -class TemplateTest(LogTrapTestCase): +class TemplateTest(unittest.TestCase): def test_simple(self): template = Template("Hello {{ name }}!") self.assertEqual(template.generate(name="Ben"), @@ -235,7 +236,7 @@ three{%end%} traceback.format_exc()) -class AutoEscapeTest(LogTrapTestCase): +class AutoEscapeTest(unittest.TestCase): def setUp(self): self.templates = { "escaped.html": "{% autoescape xhtml_escape %}{{ name }}", @@ -359,7 +360,7 @@ raw: {% raw name %}""", b("""s = "['not a string']"\n""")) -class TemplateLoaderTest(LogTrapTestCase): +class TemplateLoaderTest(unittest.TestCase): def setUp(self): self.loader = Loader(os.path.join(os.path.dirname(__file__), "templates")) diff --git a/tornado/test/testing_test.py b/tornado/test/testing_test.py index 77f55e7e5..943f49f6c 100644 --- a/tornado/test/testing_test.py +++ b/tornado/test/testing_test.py @@ -2,11 +2,11 @@ from __future__ import absolute_import, division, with_statement import time -from tornado.testing import AsyncTestCase, LogTrapTestCase +from tornado.testing import AsyncTestCase from tornado.test.util import unittest -class AsyncTestCaseTest(AsyncTestCase, LogTrapTestCase): +class AsyncTestCaseTest(AsyncTestCase): def test_exception_in_callback(self): self.io_loop.add_callback(lambda: 1 / 0) try: diff --git a/tornado/test/web_test.py b/tornado/test/web_test.py index 3418ec42e..e13adaa1d 100644 --- a/tornado/test/web_test.py +++ b/tornado/test/web_test.py @@ -188,7 +188,7 @@ class AuthRedirectRequestHandler(RequestHandler): self.send_error(500) -class AuthRedirectTest(AsyncHTTPTestCase, LogTrapTestCase): +class AuthRedirectTest(AsyncHTTPTestCase): def get_app(self): return Application([('/relative', AuthRedirectRequestHandler, dict(login_url='/login')), @@ -269,7 +269,7 @@ class EchoHandler(RequestHandler): args=recursive_unicode(self.request.arguments))) -class RequestEncodingTest(AsyncHTTPTestCase, LogTrapTestCase): +class RequestEncodingTest(AsyncHTTPTestCase): def get_app(self): return Application([ ("/group/(.*)", EchoHandler), @@ -449,7 +449,7 @@ class HeaderInjectionHandler(RequestHandler): # This test is shared with wsgi_test.py -class WSGISafeWebTest(AsyncHTTPTestCase, LogTrapTestCase): +class WSGISafeWebTest(AsyncHTTPTestCase): COOKIE_SECRET = "WebTest.COOKIE_SECRET" def get_app(self): @@ -589,7 +589,7 @@ js_embed() self.assertEqual(response.body, b("ok")) -class NonWSGIWebTests(AsyncHTTPTestCase, LogTrapTestCase): +class NonWSGIWebTests(AsyncHTTPTestCase): def get_app(self): urls = [ ("/flow_control", FlowControlHandler), @@ -688,7 +688,7 @@ class ErrorResponseTest(AsyncHTTPTestCase, LogTrapTestCase): self.assertEqual(b(""), response.body) -class StaticFileTest(AsyncHTTPTestCase, LogTrapTestCase): +class StaticFileTest(AsyncHTTPTestCase): def get_app(self): class StaticUrlHandler(RequestHandler): def get(self, path): @@ -801,7 +801,7 @@ class CustomStaticFileTest(AsyncHTTPTestCase, LogTrapTestCase): self.assertEqual(response.body, b("/static/foo.42.txt")) -class NamedURLSpecGroupsTest(AsyncHTTPTestCase, LogTrapTestCase): +class NamedURLSpecGroupsTest(AsyncHTTPTestCase): def get_app(self): class EchoHandler(RequestHandler): def get(self, path): diff --git a/tornado/test/wsgi_test.py b/tornado/test/wsgi_test.py index 4eb4bfa93..a14324807 100644 --- a/tornado/test/wsgi_test.py +++ b/tornado/test/wsgi_test.py @@ -3,13 +3,13 @@ from wsgiref.validate import validator from tornado.escape import json_decode from tornado.test.httpserver_test import TypeCheckHandler -from tornado.testing import AsyncHTTPTestCase, LogTrapTestCase +from tornado.testing import AsyncHTTPTestCase from tornado.util import b from tornado.web import RequestHandler from tornado.wsgi import WSGIApplication, WSGIContainer -class WSGIContainerTest(AsyncHTTPTestCase, LogTrapTestCase): +class WSGIContainerTest(AsyncHTTPTestCase): def wsgi_app(self, environ, start_response): status = "200 OK" response_headers = [("Content-Type", "text/plain")] @@ -24,7 +24,7 @@ class WSGIContainerTest(AsyncHTTPTestCase, LogTrapTestCase): self.assertEqual(response.body, b("Hello world!")) -class WSGIApplicationTest(AsyncHTTPTestCase, LogTrapTestCase): +class WSGIApplicationTest(AsyncHTTPTestCase): def get_app(self): class HelloHandler(RequestHandler): def get(self):