Skip to content

Commit

Permalink
Autopep8 cleanups.
Browse files Browse the repository at this point in the history
  • Loading branch information
bdarnell committed Aug 27, 2012
1 parent 0cb3924 commit 06c0903
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tornado/auth.py
Expand Up @@ -862,7 +862,7 @@ def get_authenticated_user(self, callback):
self._on_get_user_info, callback, session), self._on_get_user_info, callback, session),
session_key=session["session_key"], session_key=session["session_key"],
uids=session["uid"], 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") "profile_url,username")


def facebook_request(self, method, callback, **args): def facebook_request(self, method, callback, **args):
Expand Down
1 change: 0 additions & 1 deletion tornado/iostream.py
Expand Up @@ -670,7 +670,6 @@ def _do_ssl_handshake(self):
self._ssl_connect_callback = None self._ssl_connect_callback = None
self._run_callback(callback) self._run_callback(callback)



def _handle_read(self): def _handle_read(self):
if self._ssl_accepting: if self._ssl_accepting:
self._do_ssl_handshake() self._do_ssl_handshake()
Expand Down
2 changes: 1 addition & 1 deletion tornado/platform/twisted.py
Expand Up @@ -281,7 +281,7 @@ def getWriters(self):
# IOLoop.start() instead of Reactor.run(). # IOLoop.start() instead of Reactor.run().
def stop(self): def stop(self):
PosixReactorBase.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) self._io_loop.add_callback(fire_shutdown)


def crash(self): def crash(self):
Expand Down
2 changes: 1 addition & 1 deletion tornado/stack_context.py
Expand Up @@ -197,7 +197,7 @@ def wrap(fn):


def wrapped(*args, **kwargs): def wrapped(*args, **kwargs):
callback, contexts, args = args[0], args[1], args[2:] callback, contexts, args = args[0], args[1], args[2:]

if contexts is _state.contexts or not contexts: if contexts is _state.contexts or not contexts:
callback(*args, **kwargs) callback(*args, **kwargs)
return return
Expand Down
2 changes: 1 addition & 1 deletion tornado/test/httpserver_test.py
Expand Up @@ -56,7 +56,7 @@ def get_app(self):


class SSLTestMixin(object): class SSLTestMixin(object):
def get_ssl_options(self): 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()) **AsyncHTTPSTestCase.get_ssl_options())


def get_ssl_version(self): def get_ssl_version(self):
Expand Down
8 changes: 7 additions & 1 deletion tornado/test/iostream_test.py
Expand Up @@ -79,6 +79,7 @@ def test_read_zero_bytes(self):
def test_write_while_connecting(self): def test_write_while_connecting(self):
stream = self._make_client_iostream() stream = self._make_client_iostream()
connected = [False] connected = [False]

def connected_callback(): def connected_callback():
connected[0] = True connected[0] = True
self.stop() self.stop()
Expand All @@ -87,6 +88,7 @@ def connected_callback():
# unlike the previous tests, try to write before the connection # unlike the previous tests, try to write before the connection
# is complete. # is complete.
written = [False] written = [False]

def write_callback(): def write_callback():
written[0] = True written[0] = True
self.stop() self.stop()
Expand All @@ -111,7 +113,7 @@ class TestIOStreamMixin(object):
def _make_server_iostream(self, connection, **kwargs): def _make_server_iostream(self, connection, **kwargs):
raise NotImplementedError() raise NotImplementedError()


def _make_client_iostream(self, connection ,**kwargs): def _make_client_iostream(self, connection, **kwargs):
raise NotImplementedError() raise NotImplementedError()


def make_iostream_pair(self, **kwargs): def make_iostream_pair(self, **kwargs):
Expand Down Expand Up @@ -346,23 +348,27 @@ def test_close_callback_with_pending_read(self):
server.close() server.close()
client.close() client.close()



class TestIOStreamWebHTTP(TestIOStreamWebMixin, AsyncHTTPTestCase, class TestIOStreamWebHTTP(TestIOStreamWebMixin, AsyncHTTPTestCase,
LogTrapTestCase): LogTrapTestCase):
def _make_client_iostream(self): def _make_client_iostream(self):
return IOStream(socket.socket(), io_loop=self.io_loop) return IOStream(socket.socket(), io_loop=self.io_loop)



class TestIOStreamWebHTTPS(TestIOStreamWebMixin, AsyncHTTPSTestCase, class TestIOStreamWebHTTPS(TestIOStreamWebMixin, AsyncHTTPSTestCase,
LogTrapTestCase): LogTrapTestCase):
def _make_client_iostream(self): def _make_client_iostream(self):
return SSLIOStream(socket.socket(), io_loop=self.io_loop) return SSLIOStream(socket.socket(), io_loop=self.io_loop)



class TestIOStream(TestIOStreamMixin, AsyncTestCase, LogTrapTestCase): class TestIOStream(TestIOStreamMixin, AsyncTestCase, LogTrapTestCase):
def _make_server_iostream(self, connection, **kwargs): def _make_server_iostream(self, connection, **kwargs):
return IOStream(connection, io_loop=self.io_loop, **kwargs) return IOStream(connection, io_loop=self.io_loop, **kwargs)


def _make_client_iostream(self, connection, **kwargs): def _make_client_iostream(self, connection, **kwargs):
return IOStream(connection, io_loop=self.io_loop, **kwargs) return IOStream(connection, io_loop=self.io_loop, **kwargs)



class TestIOStreamSSL(TestIOStreamMixin, AsyncTestCase, LogTrapTestCase): class TestIOStreamSSL(TestIOStreamMixin, AsyncTestCase, LogTrapTestCase):
def _make_server_iostream(self, connection, **kwargs): def _make_server_iostream(self, connection, **kwargs):
ssl_options = dict( ssl_options = dict(
Expand Down
1 change: 1 addition & 0 deletions tornado/test/locale_test.py
Expand Up @@ -4,6 +4,7 @@
import tornado.locale import tornado.locale
import unittest import unittest



class TranslationLoaderTest(unittest.TestCase): class TranslationLoaderTest(unittest.TestCase):
# TODO: less hacky way to get isolated tests # TODO: less hacky way to get isolated tests
SAVE_VARS = ['_translations', '_supported_locales', '_use_gettext'] SAVE_VARS = ['_translations', '_supported_locales', '_use_gettext']
Expand Down
1 change: 1 addition & 0 deletions tornado/test/options_test.py
Expand Up @@ -11,6 +11,7 @@
from tornado.options import _Options, _LogFormatter from tornado.options import _Options, _LogFormatter
from tornado.util import b, bytes_type from tornado.util import b, bytes_type



@contextlib.contextmanager @contextlib.contextmanager
def ignore_bytes_warning(): def ignore_bytes_warning():
if not hasattr(warnings, 'catch_warnings'): if not hasattr(warnings, 'catch_warnings'):
Expand Down
2 changes: 1 addition & 1 deletion tornado/test/runtests.py
Expand Up @@ -55,7 +55,7 @@ def all():


import tornado.testing import tornado.testing
kwargs = {} kwargs = {}
if sys.version_info >= (3,2): if sys.version_info >= (3, 2):
# HACK: unittest.main will make its own changes to the warning # HACK: unittest.main will make its own changes to the warning
# configuration, which may conflict with the settings above # configuration, which may conflict with the settings above
# or command-line flags like -bb. Passing warnings=False # or command-line flags like -bb. Passing warnings=False
Expand Down
1 change: 1 addition & 0 deletions tornado/test/twisted_test.py
Expand Up @@ -230,6 +230,7 @@ def doWrite(self):
if have_twisted: if have_twisted:
Writer = implementer(IWriteDescriptor)(Writer) Writer = implementer(IWriteDescriptor)(Writer)



class ReactorReaderWriterTest(ReactorTestCase): class ReactorReaderWriterTest(ReactorTestCase):
def _set_nonblocking(self, fd): def _set_nonblocking(self, fd):
flags = fcntl.fcntl(fd, fcntl.F_GETFL) flags = fcntl.fcntl(fd, fcntl.F_GETFL)
Expand Down
1 change: 1 addition & 0 deletions tornado/test/wsgi_test.py
Expand Up @@ -73,6 +73,7 @@ class WSGIConnectionTest(HTTPConnectionTest):
def get_app(self): def get_app(self):
return WSGIContainer(validator(WSGIApplication(self.get_handlers()))) return WSGIContainer(validator(WSGIApplication(self.get_handlers())))



class WSGIWebTest(WSGISafeWebTest): class WSGIWebTest(WSGISafeWebTest):
def get_app(self): def get_app(self):
self.app = WSGIApplication(self.get_handlers(), **self.get_app_kwargs()) self.app = WSGIApplication(self.get_handlers(), **self.get_app_kwargs())
Expand Down
1 change: 0 additions & 1 deletion tornado/testing.py
Expand Up @@ -247,7 +247,6 @@ def get_http_server(self):
return HTTPServer(self._app, io_loop=self.io_loop, return HTTPServer(self._app, io_loop=self.io_loop,
**self.get_httpserver_options()) **self.get_httpserver_options())



def get_app(self): def get_app(self):
"""Should be overridden by subclasses to return a """Should be overridden by subclasses to return a
tornado.web.Application or other HTTPServer callback. tornado.web.Application or other HTTPServer callback.
Expand Down
2 changes: 1 addition & 1 deletion tornado/web.py
Expand Up @@ -1577,7 +1577,7 @@ def get(self, path, include_body=True):
cache_time = self.get_cache_time(path, modified, mime_type) cache_time = self.get_cache_time(path, modified, mime_type)


if cache_time > 0: if cache_time > 0:
self.set_header("Expires", datetime.datetime.utcnow() + \ self.set_header("Expires", datetime.datetime.utcnow() +
datetime.timedelta(seconds=cache_time)) datetime.timedelta(seconds=cache_time))
self.set_header("Cache-Control", "max-age=" + str(cache_time)) self.set_header("Cache-Control", "max-age=" + str(cache_time))
else: else:
Expand Down

0 comments on commit 06c0903

Please sign in to comment.