diff --git a/tornado/auth.py b/tornado/auth.py index 9410c36880d52cf41f8b9ebefc07f3fb491faf53..14d9d7753ce5483c7d7fda8d0181aacc26fda2e6 100644 --- a/tornado/auth.py +++ b/tornado/auth.py @@ -862,7 +862,7 @@ class FacebookMixin(object): self._on_get_user_info, callback, session), session_key=session["session_key"], uids=session["uid"], - fields="uid,first_name,last_name,name,locale,pic_square," \ + fields="uid,first_name,last_name,name,locale,pic_square," "profile_url,username") def facebook_request(self, method, callback, **args): diff --git a/tornado/iostream.py b/tornado/iostream.py index e73df0deeeb9adbe82e2e5f82ffbda366876a3ae..25caf3ee6aa4b329c7b8e69d82ab94339d4b17d4 100644 --- a/tornado/iostream.py +++ b/tornado/iostream.py @@ -670,7 +670,6 @@ class SSLIOStream(IOStream): self._ssl_connect_callback = None self._run_callback(callback) - def _handle_read(self): if self._ssl_accepting: self._do_ssl_handshake() diff --git a/tornado/platform/twisted.py b/tornado/platform/twisted.py index 935b6233ee61782351a3da16a9a2133c5daf8294..5513964075b9199530d4229661ef601052149ccd 100644 --- a/tornado/platform/twisted.py +++ b/tornado/platform/twisted.py @@ -281,7 +281,7 @@ class TornadoReactor(PosixReactorBase): # IOLoop.start() instead of Reactor.run(). def stop(self): PosixReactorBase.stop(self) - fire_shutdown = functools.partial(self.fireSystemEvent,"shutdown") + fire_shutdown = functools.partial(self.fireSystemEvent, "shutdown") self._io_loop.add_callback(fire_shutdown) def crash(self): diff --git a/tornado/stack_context.py b/tornado/stack_context.py index afce681ba061d81cbb6967277f04d216e5b90a75..e70fe53d8b3d148649ee1453935b35bd48622158 100644 --- a/tornado/stack_context.py +++ b/tornado/stack_context.py @@ -197,7 +197,7 @@ def wrap(fn): def wrapped(*args, **kwargs): callback, contexts, args = args[0], args[1], args[2:] - + if contexts is _state.contexts or not contexts: callback(*args, **kwargs) return diff --git a/tornado/test/httpserver_test.py b/tornado/test/httpserver_test.py index e9078da2801d7492f7b2f51e8ce15543d6bc8184..190f1abc3bbd5a777eb16f10fb9aa2396514f423 100644 --- a/tornado/test/httpserver_test.py +++ b/tornado/test/httpserver_test.py @@ -56,7 +56,7 @@ class BaseSSLTest(AsyncHTTPSTestCase, LogTrapTestCase): class SSLTestMixin(object): def get_ssl_options(self): - return dict(ssl_version = self.get_ssl_version(), + return dict(ssl_version=self.get_ssl_version(), **AsyncHTTPSTestCase.get_ssl_options()) def get_ssl_version(self): diff --git a/tornado/test/iostream_test.py b/tornado/test/iostream_test.py index e58d0f77ecaf35ee47d134691f6378d99aae9011..3b051d34e8233af58aacc988bb60cf16bcb3fad0 100644 --- a/tornado/test/iostream_test.py +++ b/tornado/test/iostream_test.py @@ -79,6 +79,7 @@ class TestIOStreamWebMixin(object): def test_write_while_connecting(self): stream = self._make_client_iostream() connected = [False] + def connected_callback(): connected[0] = True self.stop() @@ -87,6 +88,7 @@ class TestIOStreamWebMixin(object): # unlike the previous tests, try to write before the connection # is complete. written = [False] + def write_callback(): written[0] = True self.stop() @@ -111,7 +113,7 @@ class TestIOStreamMixin(object): def _make_server_iostream(self, connection, **kwargs): raise NotImplementedError() - def _make_client_iostream(self, connection ,**kwargs): + def _make_client_iostream(self, connection, **kwargs): raise NotImplementedError() def make_iostream_pair(self, **kwargs): @@ -346,16 +348,19 @@ class TestIOStreamMixin(object): server.close() client.close() + class TestIOStreamWebHTTP(TestIOStreamWebMixin, AsyncHTTPTestCase, LogTrapTestCase): def _make_client_iostream(self): return IOStream(socket.socket(), io_loop=self.io_loop) + class TestIOStreamWebHTTPS(TestIOStreamWebMixin, AsyncHTTPSTestCase, LogTrapTestCase): def _make_client_iostream(self): return SSLIOStream(socket.socket(), io_loop=self.io_loop) + class TestIOStream(TestIOStreamMixin, AsyncTestCase, LogTrapTestCase): def _make_server_iostream(self, connection, **kwargs): return IOStream(connection, io_loop=self.io_loop, **kwargs) @@ -363,6 +368,7 @@ class TestIOStream(TestIOStreamMixin, AsyncTestCase, LogTrapTestCase): def _make_client_iostream(self, connection, **kwargs): return IOStream(connection, io_loop=self.io_loop, **kwargs) + class TestIOStreamSSL(TestIOStreamMixin, AsyncTestCase, LogTrapTestCase): def _make_server_iostream(self, connection, **kwargs): ssl_options = dict( diff --git a/tornado/test/locale_test.py b/tornado/test/locale_test.py index 333fa05d95bb5cd75672796c8a7a6eb890166079..586080b1e31dceba396bb0239c4d3e6ba347827d 100644 --- a/tornado/test/locale_test.py +++ b/tornado/test/locale_test.py @@ -4,6 +4,7 @@ import os import tornado.locale import unittest + class TranslationLoaderTest(unittest.TestCase): # TODO: less hacky way to get isolated tests SAVE_VARS = ['_translations', '_supported_locales', '_use_gettext'] diff --git a/tornado/test/options_test.py b/tornado/test/options_test.py index f792329df563845d7915c47fdee323ec30c984c3..29ce177ff7e799b06c66bda99c48f84cec3c86b3 100644 --- a/tornado/test/options_test.py +++ b/tornado/test/options_test.py @@ -11,6 +11,7 @@ from tornado.escape import utf8 from tornado.options import _Options, _LogFormatter from tornado.util import b, bytes_type + @contextlib.contextmanager def ignore_bytes_warning(): if not hasattr(warnings, 'catch_warnings'): diff --git a/tornado/test/runtests.py b/tornado/test/runtests.py index a7a73e1ff986f092ee887aebcecc62aad246d045..eea052ea1cb9d4687ecb063408fc519c8622c5e3 100644 --- a/tornado/test/runtests.py +++ b/tornado/test/runtests.py @@ -55,7 +55,7 @@ if __name__ == '__main__': import tornado.testing kwargs = {} - if sys.version_info >= (3,2): + if sys.version_info >= (3, 2): # HACK: unittest.main will make its own changes to the warning # configuration, which may conflict with the settings above # or command-line flags like -bb. Passing warnings=False diff --git a/tornado/test/twisted_test.py b/tornado/test/twisted_test.py index 1a454817f36b98cc71466284493bff2a7be39484..2ebbb8945b34c3bb4d34e4759017b2741479256a 100644 --- a/tornado/test/twisted_test.py +++ b/tornado/test/twisted_test.py @@ -230,6 +230,7 @@ class Writer(object): if have_twisted: Writer = implementer(IWriteDescriptor)(Writer) + class ReactorReaderWriterTest(ReactorTestCase): def _set_nonblocking(self, fd): flags = fcntl.fcntl(fd, fcntl.F_GETFL) diff --git a/tornado/test/wsgi_test.py b/tornado/test/wsgi_test.py index c3a8cfefc7bbc93f01b58ac8696c640a09f6f740..568bb116ebf0db263de139e767f18adc1e648bea 100644 --- a/tornado/test/wsgi_test.py +++ b/tornado/test/wsgi_test.py @@ -73,6 +73,7 @@ class WSGIConnectionTest(HTTPConnectionTest): def get_app(self): return WSGIContainer(validator(WSGIApplication(self.get_handlers()))) + class WSGIWebTest(WSGISafeWebTest): def get_app(self): self.app = WSGIApplication(self.get_handlers(), **self.get_app_kwargs()) diff --git a/tornado/testing.py b/tornado/testing.py index 42fec8e722867fff57943bab68c618b245dd2e6a..c18f17be30c01dc872969476aeac2ea9ebb3b193 100644 --- a/tornado/testing.py +++ b/tornado/testing.py @@ -247,7 +247,6 @@ class AsyncHTTPTestCase(AsyncTestCase): return HTTPServer(self._app, io_loop=self.io_loop, **self.get_httpserver_options()) - def get_app(self): """Should be overridden by subclasses to return a tornado.web.Application or other HTTPServer callback. diff --git a/tornado/web.py b/tornado/web.py index f7eda1f581dfedd1afd279950e0fa250f14f8a49..4d5e632e71b387bf73cae2a941556d734b978cee 100644 --- a/tornado/web.py +++ b/tornado/web.py @@ -1577,7 +1577,7 @@ class StaticFileHandler(RequestHandler): cache_time = self.get_cache_time(path, modified, mime_type) if cache_time > 0: - self.set_header("Expires", datetime.datetime.utcnow() + \ + self.set_header("Expires", datetime.datetime.utcnow() + datetime.timedelta(seconds=cache_time)) self.set_header("Cache-Control", "max-age=" + str(cache_time)) else: