From: Pierce Lopez Date: Mon, 1 Jan 2018 22:54:33 +0000 (-0500) Subject: style fix: wrap or ignore long lines in some tests X-Git-Tag: v5.0.0~20^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=120afef8e7a7c0b12a28dafd30e50570e80994eb;p=thirdparty%2Ftornado.git style fix: wrap or ignore long lines in some tests template_test: rewrite long lambda to avoid long line --- diff --git a/tornado/test/simple_httpclient_test.py b/tornado/test/simple_httpclient_test.py index f96639e22..f32319e59 100644 --- a/tornado/test/simple_httpclient_test.py +++ b/tornado/test/simple_httpclient_test.py @@ -20,7 +20,7 @@ from tornado.log import gen_log from tornado.concurrent import Future from tornado.netutil import Resolver, bind_sockets from tornado.simple_httpclient import SimpleAsyncHTTPClient -from tornado.test.httpclient_test import ChunkHandler, CountdownHandler, HelloWorldHandler, RedirectHandler +from tornado.test.httpclient_test import ChunkHandler, CountdownHandler, HelloWorldHandler, RedirectHandler # noqa: E501 from tornado.test import httpclient_test from tornado.testing import AsyncHTTPTestCase, AsyncHTTPSTestCase, AsyncTestCase, ExpectLog from tornado.test.util import skipOnTravis, skipIfNoIPv6, refusing_port, skipBefore35, exec_test diff --git a/tornado/test/template_test.py b/tornado/test/template_test.py index 2f1e88c1d..41c1c90c6 100644 --- a/tornado/test/template_test.py +++ b/tornado/test/template_test.py @@ -208,10 +208,15 @@ three{%end%} self.assertTrue("# test.html:2" in traceback.format_exc()) def test_error_line_number_module(self): + loader = None + + def load_generate(path, **kwargs): + return loader.load(path).generate(**kwargs) + loader = DictLoader({ "base.html": "{% module Template('sub.html') %}", "sub.html": "{{1/0}}", - }, namespace={"_tt_modules": ObjectDict(Template=lambda path, **kwargs: loader.load(path).generate(**kwargs))}) + }, namespace={"_tt_modules": ObjectDict(Template=load_generate)}) try: loader.load("base.html").generate() self.fail("did not get expected exception") diff --git a/tornado/test/util_test.py b/tornado/test/util_test.py index 48924d44b..21ddf2412 100644 --- a/tornado/test/util_test.py +++ b/tornado/test/util_test.py @@ -6,8 +6,11 @@ import datetime import tornado.escape from tornado.escape import utf8 -from tornado.util import raise_exc_info, Configurable, exec_in, ArgReplacer, timedelta_to_seconds, import_object, re_unescape, is_finalizing, PY3 from tornado.test.util import unittest +from tornado.util import ( + raise_exc_info, Configurable, exec_in, ArgReplacer, + timedelta_to_seconds, import_object, re_unescape, is_finalizing, PY3, +) if PY3: from io import StringIO diff --git a/tornado/test/web_test.py b/tornado/test/web_test.py index 46390e0d1..646b2f796 100644 --- a/tornado/test/web_test.py +++ b/tornado/test/web_test.py @@ -1,7 +1,8 @@ from __future__ import absolute_import, division, print_function + from tornado.concurrent import Future from tornado import gen -from tornado.escape import json_decode, utf8, to_unicode, recursive_unicode, native_str, to_basestring +from tornado.escape import json_decode, utf8, to_unicode, recursive_unicode, native_str, to_basestring # noqa: E501 from tornado.httputil import format_timestamp from tornado.ioloop import IOLoop from tornado.iostream import IOStream @@ -12,7 +13,12 @@ from tornado.template import DictLoader from tornado.testing import AsyncHTTPTestCase, AsyncTestCase, ExpectLog, gen_test from tornado.test.util import unittest, skipBefore35, exec_test from tornado.util import ObjectDict, unicode_type, timedelta_to_seconds, PY3 -from tornado.web import RequestHandler, authenticated, Application, asynchronous, url, HTTPError, StaticFileHandler, _create_signature_v1, create_signed_value, decode_signed_value, ErrorHandler, UIModule, MissingArgumentError, stream_request_body, Finish, removeslash, addslash, RedirectHandler as WebRedirectHandler, get_signature_key_version, GZipContentEncoding +from tornado.web import ( + Application, RequestHandler, StaticFileHandler, RedirectHandler as WebRedirectHandler, + HTTPError, MissingArgumentError, ErrorHandler, authenticated, asynchronous, url, + _create_signature_v1, create_signed_value, decode_signed_value, get_signature_key_version, + UIModule, Finish, stream_request_body, removeslash, addslash, GZipContentEncoding, +) import binascii import contextlib @@ -635,7 +641,12 @@ class WSGISafeWebTest(WebTestCase): {% end %} """, "entry.html": """\ -{{ set_resources(embedded_css=".entry { margin-bottom: 1em; }", embedded_javascript="js_embed()", css_files=["/base.css", "/foo.css"], javascript_files="/common.js", html_head="", html_body='