summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2022-01-02 02:18:15 +0000
committerGerrit Code Review <gerrit@ci3.zzzcomputing.com>2022-01-02 02:18:15 +0000
commit7de5b2a0c23527fba0e6abe4a1e20f39c0760141 (patch)
tree5d14fa5fbd787a627b59f670bcadfc8a2a5d3116
parentd5312ebd1332e54a6248435230aa2bef241879b0 (diff)
parent1b30aa5f4bca03c66d4b8974093bd96109ab0a93 (diff)
downloadmako-7de5b2a0c23527fba0e6abe4a1e20f39c0760141.tar.gz
Merge "Remove Python 2 residue; use Python 3 idioms" into main
-rw-r--r--doc/build/conf.py21
-rw-r--r--mako/ast.py6
-rwxr-xr-xmako/cmd.py5
-rw-r--r--mako/compat.py4
-rw-r--r--mako/ext/babelplugin.py2
-rw-r--r--mako/ext/beaker_cache.py2
-rw-r--r--mako/ext/pygmentplugin.py10
-rw-r--r--mako/parsetree.py42
-rw-r--r--test/ext/test_babelplugin.py4
-rw-r--r--test/test_ast.py66
-rw-r--r--test/test_cache.py8
-rw-r--r--test/test_exceptions.py1
-rw-r--r--test/test_filters.py2
-rw-r--r--test/test_lexer.py2
-rw-r--r--test/test_loop.py2
-rw-r--r--test/test_template.py2
-rw-r--r--test/test_util.py2
17 files changed, 77 insertions, 104 deletions
diff --git a/doc/build/conf.py b/doc/build/conf.py
index 8fc794e..49a8fe9 100644
--- a/doc/build/conf.py
+++ b/doc/build/conf.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Mako documentation build configuration file
#
@@ -78,8 +77,8 @@ source_suffix = ".rst"
master_doc = "index"
# General information about the project.
-project = u"Mako"
-copyright = u"the Mako authors and contributors"
+project = "Mako"
+copyright = "the Mako authors and contributors"
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
@@ -89,7 +88,7 @@ copyright = u"the Mako authors and contributors"
version = mako.__version__
# The full version, including alpha/beta/rc tags.
release = "1.1.5"
-
+release_date = None
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
# language = None
@@ -230,8 +229,8 @@ latex_documents = [
(
"index",
"mako_%s.tex" % release.replace(".", "_"),
- u"Mako Documentation",
- u"Mike Bayer",
+ "Mako Documentation",
+ "Mike Bayer",
"manual",
)
]
@@ -269,16 +268,16 @@ latex_preamble = r"\setcounter{tocdepth}{3}"
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
-man_pages = [("index", "mako", u"Mako Documentation", [u"Mako authors"], 1)]
+man_pages = [("index", "mako", "Mako Documentation", ["Mako authors"], 1)]
# -- Options for Epub output ---------------------------------------------------
# Bibliographic Dublin Core info.
-epub_title = u"Mako"
-epub_author = u"Mako authors"
-epub_publisher = u"Mako authors"
-epub_copyright = u"Mako authors"
+epub_title = "Mako"
+epub_author = "Mako authors"
+epub_publisher = "Mako authors"
+epub_copyright = "Mako authors"
# The language of the text. It defaults to the language option
# or en if the language is not set.
diff --git a/mako/ast.py b/mako/ast.py
index 6023ede..f879e8b 100644
--- a/mako/ast.py
+++ b/mako/ast.py
@@ -107,7 +107,7 @@ class PythonFragment(PythonCode):
"Unsupported control keyword: '%s'" % keyword,
**exception_kwargs,
)
- super(PythonFragment, self).__init__(code, **exception_kwargs)
+ super().__init__(code, **exception_kwargs)
class FunctionDecl:
@@ -199,6 +199,4 @@ class FunctionArgs(FunctionDecl):
"""the argument portion of a function declaration"""
def __init__(self, code, **kwargs):
- super(FunctionArgs, self).__init__(
- "def ANON(%s):pass" % code, **kwargs
- )
+ super().__init__("def ANON(%s):pass" % code, **kwargs)
diff --git a/mako/cmd.py b/mako/cmd.py
index 986a1d2..7592fb2 100755
--- a/mako/cmd.py
+++ b/mako/cmd.py
@@ -4,7 +4,6 @@
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
from argparse import ArgumentParser
-import io
from os.path import dirname
from os.path import isfile
import sys
@@ -92,9 +91,7 @@ def cmdline(argv=None):
_exit()
else:
if output_file:
- io.open(output_file, "wt", encoding=output_encoding).write(
- rendered
- )
+ open(output_file, "wt", encoding=output_encoding).write(rendered)
else:
sys.stdout.write(rendered)
diff --git a/mako/compat.py b/mako/compat.py
index 5ffb593..68bc03b 100644
--- a/mako/compat.py
+++ b/mako/compat.py
@@ -24,11 +24,11 @@ def inspect_getargspec(func):
if inspect.ismethod(func):
func = func.__func__
if not inspect.isfunction(func):
- raise TypeError("{!r} is not a Python function".format(func))
+ raise TypeError(f"{func!r} is not a Python function")
co = func.__code__
if not inspect.iscode(co):
- raise TypeError("{!r} is not a code object".format(co))
+ raise TypeError(f"{co!r} is not a code object")
nargs = co.co_argcount
names = co.co_varnames
diff --git a/mako/ext/babelplugin.py b/mako/ext/babelplugin.py
index 84d8478..f015ec2 100644
--- a/mako/ext/babelplugin.py
+++ b/mako/ext/babelplugin.py
@@ -20,7 +20,7 @@ class BabelMakoExtractor(MessageExtractor):
"input_encoding", options.get("encoding", None)
),
}
- super(BabelMakoExtractor, self).__init__()
+ super().__init__()
def __call__(self, fileobj):
return self.process_file(fileobj)
diff --git a/mako/ext/beaker_cache.py b/mako/ext/beaker_cache.py
index 6a7e898..a40b09c 100644
--- a/mako/ext/beaker_cache.py
+++ b/mako/ext/beaker_cache.py
@@ -40,7 +40,7 @@ class BeakerCacheImpl(CacheImpl):
_beaker_cache = cache.template.cache_args["manager"]
else:
_beaker_cache = beaker_cache.CacheManager()
- super(BeakerCacheImpl, self).__init__(cache)
+ super().__init__(cache)
def _get_cache(self, **kw):
expiretime = kw.pop("timeout", None)
diff --git a/mako/ext/pygmentplugin.py b/mako/ext/pygmentplugin.py
index 9096f33..38d6a71 100644
--- a/mako/ext/pygmentplugin.py
+++ b/mako/ext/pygmentplugin.py
@@ -106,7 +106,7 @@ class MakoHtmlLexer(DelegatingLexer):
aliases = ["html+mako"]
def __init__(self, **options):
- super(MakoHtmlLexer, self).__init__(HtmlLexer, MakoLexer, **options)
+ super().__init__(HtmlLexer, MakoLexer, **options)
class MakoXmlLexer(DelegatingLexer):
@@ -114,7 +114,7 @@ class MakoXmlLexer(DelegatingLexer):
aliases = ["xml+mako"]
def __init__(self, **options):
- super(MakoXmlLexer, self).__init__(XmlLexer, MakoLexer, **options)
+ super().__init__(XmlLexer, MakoLexer, **options)
class MakoJavascriptLexer(DelegatingLexer):
@@ -122,9 +122,7 @@ class MakoJavascriptLexer(DelegatingLexer):
aliases = ["js+mako", "javascript+mako"]
def __init__(self, **options):
- super(MakoJavascriptLexer, self).__init__(
- JavascriptLexer, MakoLexer, **options
- )
+ super().__init__(JavascriptLexer, MakoLexer, **options)
class MakoCssLexer(DelegatingLexer):
@@ -132,7 +130,7 @@ class MakoCssLexer(DelegatingLexer):
aliases = ["css+mako"]
def __init__(self, **options):
- super(MakoCssLexer, self).__init__(CssLexer, MakoLexer, **options)
+ super().__init__(CssLexer, MakoLexer, **options)
pygments_html_formatter = HtmlFormatter(
diff --git a/mako/parsetree.py b/mako/parsetree.py
index 5cef120..2135769 100644
--- a/mako/parsetree.py
+++ b/mako/parsetree.py
@@ -50,7 +50,7 @@ class TemplateNode(Node):
"""a 'container' node that stores the overall collection of nodes."""
def __init__(self, filename):
- super(TemplateNode, self).__init__("", 0, 0, filename)
+ super().__init__("", 0, 0, filename)
self.nodes = []
self.page_attributes = {}
@@ -79,7 +79,7 @@ class ControlLine(Node):
has_loop_context = False
def __init__(self, keyword, isend, text, **kwargs):
- super(ControlLine, self).__init__(**kwargs)
+ super().__init__(**kwargs)
self.text = text
self.keyword = keyword
self.isend = isend
@@ -127,7 +127,7 @@ class Text(Node):
"""defines plain text in the template."""
def __init__(self, content, **kwargs):
- super(Text, self).__init__(**kwargs)
+ super().__init__(**kwargs)
self.content = content
def __repr__(self):
@@ -152,7 +152,7 @@ class Code(Node):
"""
def __init__(self, text, ismodule, **kwargs):
- super(Code, self).__init__(**kwargs)
+ super().__init__(**kwargs)
self.text = text
self.ismodule = ismodule
self.code = ast.PythonCode(text, **self.exception_kwargs)
@@ -179,7 +179,7 @@ class Comment(Node):
"""
def __init__(self, text, **kwargs):
- super(Comment, self).__init__(**kwargs)
+ super().__init__(**kwargs)
self.text = text
def __repr__(self):
@@ -194,7 +194,7 @@ class Expression(Node):
"""
def __init__(self, text, escapes, **kwargs):
- super(Expression, self).__init__(**kwargs)
+ super().__init__(**kwargs)
self.text = text
self.escapes = escapes
self.escapes_code = ast.ArgumentList(escapes, **self.exception_kwargs)
@@ -228,7 +228,7 @@ class _TagMeta(type):
def __init__(cls, clsname, bases, dict_):
if getattr(cls, "__keyword__", None) is not None:
cls._classmap[cls.__keyword__] = cls
- super(_TagMeta, cls).__init__(clsname, bases, dict_)
+ super().__init__(clsname, bases, dict_)
def __call__(cls, keyword, attributes, **kwargs):
if ":" in keyword:
@@ -293,7 +293,7 @@ class Tag(Node, metaclass=_TagMeta):
other arguments passed to the Node superclass (lineno, pos)
"""
- super(Tag, self).__init__(**kwargs)
+ super().__init__(**kwargs)
self.keyword = keyword
self.attributes = attributes
self._parse_attributes(expressions, nonexpressions)
@@ -377,7 +377,7 @@ class IncludeTag(Tag):
__keyword__ = "include"
def __init__(self, keyword, attributes, **kwargs):
- super(IncludeTag, self).__init__(
+ super().__init__(
keyword,
attributes,
("file", "import", "args"),
@@ -396,16 +396,14 @@ class IncludeTag(Tag):
identifiers = self.page_args.undeclared_identifiers.difference(
{"__DUMMY"}
).difference(self.page_args.declared_identifiers)
- return identifiers.union(
- super(IncludeTag, self).undeclared_identifiers()
- )
+ return identifiers.union(super().undeclared_identifiers())
class NamespaceTag(Tag):
__keyword__ = "namespace"
def __init__(self, keyword, attributes, **kwargs):
- super(NamespaceTag, self).__init__(
+ super().__init__(
keyword,
attributes,
("file",),
@@ -435,9 +433,7 @@ class TextTag(Tag):
__keyword__ = "text"
def __init__(self, keyword, attributes, **kwargs):
- super(TextTag, self).__init__(
- keyword, attributes, (), ("filter"), (), **kwargs
- )
+ super().__init__(keyword, attributes, (), ("filter"), (), **kwargs)
self.filter_args = ast.ArgumentList(
attributes.get("filter", ""), **self.exception_kwargs
)
@@ -456,7 +452,7 @@ class DefTag(Tag):
c for c in attributes if c.startswith("cache_")
]
- super(DefTag, self).__init__(
+ super().__init__(
keyword,
attributes,
expressions,
@@ -519,7 +515,7 @@ class BlockTag(Tag):
c for c in attributes if c.startswith("cache_")
]
- super(BlockTag, self).__init__(
+ super().__init__(
keyword,
attributes,
expressions,
@@ -575,7 +571,7 @@ class CallTag(Tag):
__keyword__ = "call"
def __init__(self, keyword, attributes, **kwargs):
- super(CallTag, self).__init__(
+ super().__init__(
keyword, attributes, ("args"), ("expr",), ("expr",), **kwargs
)
self.expression = attributes["expr"]
@@ -595,7 +591,7 @@ class CallTag(Tag):
class CallNamespaceTag(Tag):
def __init__(self, namespace, defname, attributes, **kwargs):
- super(CallNamespaceTag, self).__init__(
+ super().__init__(
namespace + ":" + defname,
attributes,
tuple(attributes.keys()) + ("args",),
@@ -632,7 +628,7 @@ class InheritTag(Tag):
__keyword__ = "inherit"
def __init__(self, keyword, attributes, **kwargs):
- super(InheritTag, self).__init__(
+ super().__init__(
keyword, attributes, ("file",), (), ("file",), **kwargs
)
@@ -648,9 +644,7 @@ class PageTag(Tag):
"enable_loop",
] + [c for c in attributes if c.startswith("cache_")]
- super(PageTag, self).__init__(
- keyword, attributes, expressions, (), (), **kwargs
- )
+ super().__init__(keyword, attributes, expressions, (), (), **kwargs)
self.body_decl = ast.FunctionArgs(
attributes.get("args", ""), **self.exception_kwargs
)
diff --git a/test/ext/test_babelplugin.py b/test/ext/test_babelplugin.py
index 9ef2daf..be3c37a 100644
--- a/test/ext/test_babelplugin.py
+++ b/test/ext/test_babelplugin.py
@@ -103,7 +103,7 @@ class ExtractMakoTestCase(TemplateTest):
)
self.addCleanup(mako_tmpl.close)
message = next(
- extract(mako_tmpl, set(["_", None]), [], {"encoding": "utf-8"})
+ extract(mako_tmpl, {"_", None}, [], {"encoding": "utf-8"})
)
assert message == (1, "_", "K\xf6ln", [])
@@ -114,7 +114,7 @@ class ExtractMakoTestCase(TemplateTest):
)
self.addCleanup(mako_tmpl.close)
message = next(
- extract(mako_tmpl, set(["_", None]), [], {"encoding": "cp1251"})
+ extract(mako_tmpl, {"_", None}, [], {"encoding": "cp1251"})
)
# "test" in Rusian. File encoding is cp1251 (aka "windows-1251")
assert message == (1, "_", "\u0442\u0435\u0441\u0442", [])
diff --git a/test/test_ast.py b/test/test_ast.py
index 3f86a86..29a8a36 100644
--- a/test/test_ast.py
+++ b/test/test_ast.py
@@ -27,17 +27,15 @@ for lar in (1,2,3):
parsed = ast.PythonCode(code, **exception_kwargs)
eq_(
parsed.declared_identifiers,
- set(
- ["a", "b", "c", "g", "h", "i", "u", "k", "j", "gh", "lar", "x"]
- ),
+ {"a", "b", "c", "g", "h", "i", "u", "k", "j", "gh", "lar", "x"},
)
eq_(
parsed.undeclared_identifiers,
- set(["x", "q", "foo", "gah", "blah"]),
+ {"x", "q", "foo", "gah", "blah"},
)
parsed = ast.PythonCode("x + 5 * (y-z)", **exception_kwargs)
- assert parsed.undeclared_identifiers == set(["x", "y", "z"])
+ assert parsed.undeclared_identifiers == {"x", "y", "z"}
assert parsed.declared_identifiers == set()
def test_locate_identifiers_2(self):
@@ -51,10 +49,10 @@ for x in data:
result.append(x+7)
"""
parsed = ast.PythonCode(code, **exception_kwargs)
- eq_(parsed.undeclared_identifiers, set(["get_data"]))
+ eq_(parsed.undeclared_identifiers, {"get_data"})
eq_(
parsed.declared_identifiers,
- set(["result", "data", "x", "hoho", "foobar", "foo", "yaya"]),
+ {"result", "data", "x", "hoho", "foobar", "foo", "yaya"},
)
def test_locate_identifiers_3(self):
@@ -68,7 +66,7 @@ for y in range(1, y):
(q for q in range (1, q))
"""
parsed = ast.PythonCode(code, **exception_kwargs)
- eq_(parsed.undeclared_identifiers, set(["x", "y", "z", "q", "range"]))
+ eq_(parsed.undeclared_identifiers, {"x", "y", "z", "q", "range"})
def test_locate_identifiers_4(self):
code = """
@@ -78,8 +76,8 @@ def mydef(mydefarg):
print("mda is", mydefarg)
"""
parsed = ast.PythonCode(code, **exception_kwargs)
- eq_(parsed.undeclared_identifiers, set(["y"]))
- eq_(parsed.declared_identifiers, set(["mydef", "x"]))
+ eq_(parsed.undeclared_identifiers, {"y"})
+ eq_(parsed.declared_identifiers, {"mydef", "x"})
def test_locate_identifiers_5(self):
code = """
@@ -89,7 +87,7 @@ except:
print(y)
"""
parsed = ast.PythonCode(code, **exception_kwargs)
- eq_(parsed.undeclared_identifiers, set(["x", "y"]))
+ eq_(parsed.undeclared_identifiers, {"x", "y"})
def test_locate_identifiers_6(self):
code = """
@@ -97,7 +95,7 @@ def foo():
return bar()
"""
parsed = ast.PythonCode(code, **exception_kwargs)
- eq_(parsed.undeclared_identifiers, set(["bar"]))
+ eq_(parsed.undeclared_identifiers, {"bar"})
code = """
def lala(x, y):
@@ -105,8 +103,8 @@ def lala(x, y):
print(x)
"""
parsed = ast.PythonCode(code, **exception_kwargs)
- eq_(parsed.undeclared_identifiers, set(["z", "x"]))
- eq_(parsed.declared_identifiers, set(["lala"]))
+ eq_(parsed.undeclared_identifiers, {"z", "x"})
+ eq_(parsed.declared_identifiers, {"lala"})
code = """
def lala(x, y):
@@ -116,15 +114,15 @@ def lala(x, y):
print(z)
"""
parsed = ast.PythonCode(code, **exception_kwargs)
- eq_(parsed.undeclared_identifiers, set(["z"]))
- eq_(parsed.declared_identifiers, set(["lala"]))
+ eq_(parsed.undeclared_identifiers, {"z"})
+ eq_(parsed.declared_identifiers, {"lala"})
def test_locate_identifiers_7(self):
code = """
import foo.bar
"""
parsed = ast.PythonCode(code, **exception_kwargs)
- eq_(parsed.declared_identifiers, set(["foo"]))
+ eq_(parsed.declared_identifiers, {"foo"})
eq_(parsed.undeclared_identifiers, set())
def test_locate_identifiers_8(self):
@@ -135,7 +133,7 @@ class Hi:
x = 5
"""
parsed = ast.PythonCode(code, **exception_kwargs)
- eq_(parsed.declared_identifiers, set(["Hi"]))
+ eq_(parsed.declared_identifiers, {"Hi"})
eq_(parsed.undeclared_identifiers, set())
def test_locate_identifiers_9(self):
@@ -143,15 +141,15 @@ class Hi:
",".join([t for t in ("a", "b", "c")])
"""
parsed = ast.PythonCode(code, **exception_kwargs)
- eq_(parsed.declared_identifiers, set(["t"]))
- eq_(parsed.undeclared_identifiers, set(["t"]))
+ eq_(parsed.declared_identifiers, {"t"})
+ eq_(parsed.undeclared_identifiers, {"t"})
code = """
[(val, name) for val, name in x]
"""
parsed = ast.PythonCode(code, **exception_kwargs)
- eq_(parsed.declared_identifiers, set(["val", "name"]))
- eq_(parsed.undeclared_identifiers, set(["val", "name", "x"]))
+ eq_(parsed.declared_identifiers, {"val", "name"})
+ eq_(parsed.undeclared_identifiers, {"val", "name", "x"})
def test_locate_identifiers_10(self):
code = """
@@ -167,7 +165,7 @@ def x(q):
return q + 5
"""
parsed = ast.PythonCode(code, **exception_kwargs)
- eq_(parsed.declared_identifiers, set(["x"]))
+ eq_(parsed.declared_identifiers, {"x"})
eq_(parsed.undeclared_identifiers, set())
def test_locate_identifiers_12(self):
@@ -178,7 +176,7 @@ def foo():
t = s
"""
parsed = ast.PythonCode(code, **exception_kwargs)
- eq_(parsed.declared_identifiers, set(["foo"]))
+ eq_(parsed.declared_identifiers, {"foo"})
eq_(parsed.undeclared_identifiers, set())
def test_locate_identifiers_13(self):
@@ -189,7 +187,7 @@ def foo():
Bat
"""
parsed = ast.PythonCode(code, **exception_kwargs)
- eq_(parsed.declared_identifiers, set(["foo"]))
+ eq_(parsed.declared_identifiers, {"foo"})
eq_(parsed.undeclared_identifiers, set())
def test_locate_identifiers_14(self):
@@ -202,8 +200,8 @@ def foo():
print(Bat)
"""
parsed = ast.PythonCode(code, **exception_kwargs)
- eq_(parsed.declared_identifiers, set(["foo"]))
- eq_(parsed.undeclared_identifiers, set(["Bat"]))
+ eq_(parsed.declared_identifiers, {"foo"})
+ eq_(parsed.undeclared_identifiers, {"Bat"})
def test_locate_identifiers_16(self):
code = """
@@ -213,7 +211,7 @@ except Exception as e:
print(y)
"""
parsed = ast.PythonCode(code, **exception_kwargs)
- eq_(parsed.undeclared_identifiers, set(["x", "y", "Exception"]))
+ eq_(parsed.undeclared_identifiers, {"x", "y", "Exception"})
def test_locate_identifiers_17(self):
code = """
@@ -223,7 +221,7 @@ except (Foo, Bar) as e:
print(y)
"""
parsed = ast.PythonCode(code, **exception_kwargs)
- eq_(parsed.undeclared_identifiers, set(["x", "y", "Foo", "Bar"]))
+ eq_(parsed.undeclared_identifiers, {"x", "y", "Foo", "Bar"})
def test_no_global_imports(self):
code = """
@@ -239,22 +237,22 @@ import x as bar
def test_python_fragment(self):
parsed = ast.PythonFragment("for x in foo:", **exception_kwargs)
- eq_(parsed.declared_identifiers, set(["x"]))
- eq_(parsed.undeclared_identifiers, set(["foo"]))
+ eq_(parsed.declared_identifiers, {"x"})
+ eq_(parsed.undeclared_identifiers, {"foo"})
parsed = ast.PythonFragment("try:", **exception_kwargs)
parsed = ast.PythonFragment(
"except MyException as e:", **exception_kwargs
)
- eq_(parsed.declared_identifiers, set(["e"]))
- eq_(parsed.undeclared_identifiers, set(["MyException"]))
+ eq_(parsed.declared_identifiers, {"e"})
+ eq_(parsed.undeclared_identifiers, {"MyException"})
def test_argument_list(self):
parsed = ast.ArgumentList(
"3, 5, 'hi', x+5, " "context.get('lala')", **exception_kwargs
)
- eq_(parsed.undeclared_identifiers, set(["x", "context"]))
+ eq_(parsed.undeclared_identifiers, {"x", "context"})
eq_(
[x for x in parsed.args],
["3", "5", "'hi'", "(x + 5)", "context.get('lala')"],
diff --git a/test/test_cache.py b/test/test_cache.py
index b48f7fb..60785f2 100644
--- a/test/test_cache.py
+++ b/test/test_cache.py
@@ -652,9 +652,7 @@ class BeakerCacheTest(RealBackendTest, CacheTest):
def _install_mock_cache(self, template, implname=None):
template.cache_args["manager"] = self._regions()
- impl = super(BeakerCacheTest, self)._install_mock_cache(
- template, implname
- )
+ impl = super()._install_mock_cache(template, implname)
return impl
def _regions(self):
@@ -680,9 +678,7 @@ class DogpileCacheTest(RealBackendTest, CacheTest):
def _install_mock_cache(self, template, implname=None):
template.cache_args["regions"] = self._regions()
template.cache_args.setdefault("region", "short")
- impl = super(DogpileCacheTest, self)._install_mock_cache(
- template, implname
- )
+ impl = super()._install_mock_cache(template, implname)
return impl
def _regions(self):
diff --git a/test/test_exceptions.py b/test/test_exceptions.py
index b4246bd..a2b8cf9 100644
--- a/test/test_exceptions.py
+++ b/test/test_exceptions.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
import sys
from mako import exceptions
diff --git a/test/test_filters.py b/test/test_filters.py
index abe19c9..b3b4753 100644
--- a/test/test_filters.py
+++ b/test/test_filters.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
import unittest
from mako.template import Template
diff --git a/test/test_lexer.py b/test/test_lexer.py
index 08201b2..43b1e7a 100644
--- a/test/test_lexer.py
+++ b/test/test_lexer.py
@@ -26,7 +26,7 @@ def repr_arg(x):
def _as_unicode(arg):
if isinstance(arg, dict):
- return dict((k, _as_unicode(v)) for k, v in arg.items())
+ return {k: _as_unicode(v) for k, v in arg.items()}
else:
return arg
diff --git a/test/test_loop.py b/test/test_loop.py
index 709ec97..be7d440 100644
--- a/test/test_loop.py
+++ b/test/test_loop.py
@@ -199,7 +199,7 @@ class TestLoopContext(unittest.TestCase):
def test_reverse_index(self):
length = len(self.iterable)
- expected = tuple([length - i - 1 for i in range(length)])
+ expected = tuple(length - i - 1 for i in range(length))
actual = tuple(self.ctx.reverse_index for i in self.ctx)
print(expected, actual)
assert expected == actual, (
diff --git a/test/test_template.py b/test/test_template.py
index ad7f59d..238b8c6 100644
--- a/test/test_template.py
+++ b/test/test_template.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
import os
import unittest
diff --git a/test/test_util.py b/test/test_util.py
index be987fe..6aa4c47 100644
--- a/test/test_util.py
+++ b/test/test_util.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
import os
import sys
import unittest