Skip to content

Commit

Permalink
Suppress tornado.access logs in tests, and remove LogTrapTestCase
Browse files Browse the repository at this point in the history
from tests that no longer produce any logs.
  • Loading branch information
bdarnell committed Sep 9, 2012
1 parent 2bc828b commit ba0b9d4
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 26 deletions.
4 changes: 2 additions & 2 deletions tornado/test/auth_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -101,7 +101,7 @@ def get(self):
self.authorize_redirect()


class AuthTest(AsyncHTTPTestCase, LogTrapTestCase):
class AuthTest(AsyncHTTPTestCase):
def get_app(self):
return Application(
[
Expand Down
4 changes: 2 additions & 2 deletions tornado/test/httpclient_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
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

Expand Down Expand Up @@ -59,7 +59,7 @@ def post(self):
# test suite.


class HTTPClientCommonTestCase(AsyncHTTPTestCase, LogTrapTestCase):
class HTTPClientCommonTestCase(AsyncHTTPTestCase):
def get_app(self):
return Application([
url("/hello", HelloWorldHandler),
Expand Down
8 changes: 4 additions & 4 deletions tornado/test/httpserver_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
ssl = None


class HandlerBaseTestCase(AsyncHTTPTestCase, LogTrapTestCase):
class HandlerBaseTestCase(AsyncHTTPTestCase):
def get_app(self):
return Application([('/', self.__class__.Handler)])

Expand Down Expand Up @@ -166,7 +166,7 @@ def _on_connect(self, parsed, parsed_hostname):
# This test is also called from wsgi_test


class HTTPConnectionTest(AsyncHTTPTestCase, LogTrapTestCase):
class HTTPConnectionTest(AsyncHTTPTestCase):
def get_handlers(self):
return [("/multipart", MultipartTestHandler),
("/hello", HelloWorldRequestHandler)]
Expand Down Expand Up @@ -288,7 +288,7 @@ def check_type(self, name, obj, expected_type):
actual_type)


class HTTPServerTest(AsyncHTTPTestCase, LogTrapTestCase):
class HTTPServerTest(AsyncHTTPTestCase):
def get_app(self):
return Application([("/echo", EchoHandler),
("/typecheck", TypeCheckHandler),
Expand Down Expand Up @@ -352,7 +352,7 @@ def test_ip_headers(self):
"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
Expand Down
4 changes: 2 additions & 2 deletions tornado/test/ioloop_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

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.
Expand Down
3 changes: 3 additions & 0 deletions tornado/test/runtests.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -66,6 +67,8 @@ def run(self, test):
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):
Expand Down
4 changes: 2 additions & 2 deletions tornado/test/simple_httpclient_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def test_connection_refused(self):
response.error)


class CreateAsyncHTTPClientTestCase(AsyncTestCase, LogTrapTestCase):
class CreateAsyncHTTPClientTestCase(AsyncTestCase):
def setUp(self):
super(CreateAsyncHTTPClientTestCase, self).setUp()
self.saved = AsyncHTTPClient._save_configuration()
Expand Down Expand Up @@ -336,7 +336,7 @@ def test_max_clients(self):
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(
Expand Down
7 changes: 4 additions & 3 deletions tornado/test/template_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
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"),
Expand Down Expand Up @@ -235,7 +236,7 @@ def test_multi_includes(self):
traceback.format_exc())


class AutoEscapeTest(LogTrapTestCase):
class AutoEscapeTest(unittest.TestCase):
def setUp(self):
self.templates = {
"escaped.html": "{% autoescape xhtml_escape %}{{ name }}",
Expand Down Expand Up @@ -359,7 +360,7 @@ def render(template, 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"))

Expand Down
4 changes: 2 additions & 2 deletions tornado/test/testing_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 6 additions & 6 deletions tornado/test/web_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def get(self):
self.send_error(500)


class AuthRedirectTest(AsyncHTTPTestCase, LogTrapTestCase):
class AuthRedirectTest(AsyncHTTPTestCase):
def get_app(self):
return Application([('/relative', AuthRedirectRequestHandler,
dict(login_url='/login')),
Expand Down Expand Up @@ -269,7 +269,7 @@ def get(self, *path_args):
args=recursive_unicode(self.request.arguments)))


class RequestEncodingTest(AsyncHTTPTestCase, LogTrapTestCase):
class RequestEncodingTest(AsyncHTTPTestCase):
def get_app(self):
return Application([
("/group/(.*)", EchoHandler),
Expand Down Expand Up @@ -449,7 +449,7 @@ def get(self):


# This test is shared with wsgi_test.py
class WSGISafeWebTest(AsyncHTTPTestCase, LogTrapTestCase):
class WSGISafeWebTest(AsyncHTTPTestCase):
COOKIE_SECRET = "WebTest.COOKIE_SECRET"

def get_app(self):
Expand Down Expand Up @@ -589,7 +589,7 @@ def test_header_injection(self):
self.assertEqual(response.body, b("ok"))


class NonWSGIWebTests(AsyncHTTPTestCase, LogTrapTestCase):
class NonWSGIWebTests(AsyncHTTPTestCase):
def get_app(self):
urls = [
("/flow_control", FlowControlHandler),
Expand Down Expand Up @@ -688,7 +688,7 @@ def test_failed_write_error(self):
self.assertEqual(b(""), response.body)


class StaticFileTest(AsyncHTTPTestCase, LogTrapTestCase):
class StaticFileTest(AsyncHTTPTestCase):
def get_app(self):
class StaticUrlHandler(RequestHandler):
def get(self, path):
Expand Down Expand Up @@ -801,7 +801,7 @@ def test_static_url(self):
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):
Expand Down
6 changes: 3 additions & 3 deletions tornado/test/wsgi_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

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")]
Expand All @@ -24,7 +24,7 @@ def test_simple(self):
self.assertEqual(response.body, b("Hello world!"))


class WSGIApplicationTest(AsyncHTTPTestCase, LogTrapTestCase):
class WSGIApplicationTest(AsyncHTTPTestCase):
def get_app(self):
class HelloHandler(RequestHandler):
def get(self):
Expand Down

0 comments on commit ba0b9d4

Please sign in to comment.