提交 06c09038 编写于 作者: B Ben Darnell

Autopep8 cleanups.

上级 0cb3924a
......@@ -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):
......
......@@ -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()
......
......@@ -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):
......
......@@ -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
......
......@@ -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):
......
......@@ -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(
......
......@@ -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']
......
......@@ -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'):
......
......@@ -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
......
......@@ -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)
......
......@@ -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())
......
......@@ -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.
......
......@@ -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:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册