From: Ben Darnell Date: Mon, 27 Aug 2012 21:33:01 +0000 (-0400) Subject: Autopep8 cleanups. X-Git-Tag: v2.4.0~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=06c09038cf33cab6e1632ef2ffc16e6a1f117484;p=thirdparty%2Ftornado.git Autopep8 cleanups. --- diff --git a/tornado/auth.py b/tornado/auth.py index 9410c3688..14d9d7753 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 e73df0dee..25caf3ee6 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 935b6233e..551396407 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 afce681ba..e70fe53d8 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 e9078da28..190f1abc3 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 e58d0f77e..3b051d34e 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 333fa05d9..586080b1e 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 f792329df..29ce177ff 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 a7a73e1ff..eea052ea1 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 1a454817f..2ebbb8945 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 c3a8cfefc..568bb116e 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 42fec8e72..c18f17be3 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 f7eda1f58..4d5e632e7 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: