[Python-modules-commits] [mako] 01/05: Import mako_1.0.4+ds1.orig.tar.gz
Piotr Ożarowski
piotr at moszumanska.debian.org
Thu Apr 14 19:29:59 UTC 2016
This is an automated email from the git hooks/post-receive script.
piotr pushed a commit to branch master
in repository mako.
commit 88956c5c9e1c96af7e6f633ebd3da7582aea387f
Author: Piotr Ożarowski <piotr at debian.org>
Date: Thu Apr 14 21:00:00 2016 +0200
Import mako_1.0.4+ds1.orig.tar.gz
---
LICENSE | 2 +-
PKG-INFO | 2 +-
doc/_sources/changelog.txt | 28 ++++++++++++++++++++++++++++
doc/build/changelog.rst | 28 ++++++++++++++++++++++++++++
mako/__init__.py | 4 ++--
mako/_ast_util.py | 2 +-
mako/ast.py | 2 +-
mako/cache.py | 2 +-
mako/cmd.py | 2 +-
mako/codegen.py | 2 +-
mako/compat.py | 1 +
mako/exceptions.py | 2 +-
mako/ext/autohandler.py | 2 +-
mako/ext/babelplugin.py | 2 +-
mako/ext/preprocessors.py | 2 +-
mako/ext/pygmentplugin.py | 2 +-
mako/ext/turbogears.py | 2 +-
mako/filters.py | 2 +-
mako/lexer.py | 28 +++++++++++++++++-----------
mako/lookup.py | 2 +-
mako/parsetree.py | 2 +-
mako/pygen.py | 2 +-
mako/pyparser.py | 2 +-
mako/runtime.py | 2 +-
mako/template.py | 10 +++++++++-
mako/util.py | 2 +-
setup.py | 29 +++++++++++++++++++++++++----
test/test_cache.py | 4 +++-
test/test_def.py | 35 +++++++++++++++++++++++++++++++++++
test/test_exceptions.py | 34 ++++++++--------------------------
test/test_lexer.py | 17 +++++++++++++++--
31 files changed, 191 insertions(+), 67 deletions(-)
diff --git a/LICENSE b/LICENSE
index 24eefa1..86543fc 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
This is the MIT license: http://www.opensource.org/licenses/mit-license.php
-Copyright (C) 2006-2015 the Mako authors and contributors <see AUTHORS file>.
+Copyright (C) 2006-2016 the Mako authors and contributors <see AUTHORS file>.
Mako is a trademark of Michael Bayer.
Permission is hereby granted, free of charge, to any person obtaining a copy of this
diff --git a/PKG-INFO b/PKG-INFO
index 6ee793f..e05f7e9 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: Mako
-Version: 1.0.3
+Version: 1.0.4
Summary: A super-fast templating language that borrows the best ideas from the existing templating languages.
Home-page: http://www.makotemplates.org/
Author: Mike Bayer
diff --git a/doc/_sources/changelog.txt b/doc/_sources/changelog.txt
index 9cf8089..c9a7551 100644
--- a/doc/_sources/changelog.txt
+++ b/doc/_sources/changelog.txt
@@ -6,6 +6,34 @@ Changelog
===
.. changelog::
+ :version: 1.0.4
+ :released: Thu Mar 10 2016
+
+ .. change::
+ :tags: feature, test
+
+ The default test runner is now py.test. Running "python setup.py test"
+ will make use of py.test instead of nose. nose still works as a test
+ runner as well, however.
+
+ .. change::
+ :tags: bug, lexer
+ :pullreq: github:19
+
+ Major improvements to lexing of intricate Python sections which may
+ contain complex backslash sequences, as well as support for the bitwise
+ operator (e.g. pipe symbol) inside of expression sections distinct
+ from the Mako "filter" operator, provided the operator is enclosed
+ within parentheses or brackets. Pull request courtesy Daniel Martin.
+
+ .. change::
+ :tags: feature
+ :pullreq: bitbucket:16
+
+ Added new method :meth:`.Template.list_defs`. Pull request courtesy
+ Jonathan Vanasco.
+
+.. changelog::
:version: 1.0.3
:released: Tue Oct 27 2015
diff --git a/doc/build/changelog.rst b/doc/build/changelog.rst
index 9cf8089..c9a7551 100644
--- a/doc/build/changelog.rst
+++ b/doc/build/changelog.rst
@@ -6,6 +6,34 @@ Changelog
===
.. changelog::
+ :version: 1.0.4
+ :released: Thu Mar 10 2016
+
+ .. change::
+ :tags: feature, test
+
+ The default test runner is now py.test. Running "python setup.py test"
+ will make use of py.test instead of nose. nose still works as a test
+ runner as well, however.
+
+ .. change::
+ :tags: bug, lexer
+ :pullreq: github:19
+
+ Major improvements to lexing of intricate Python sections which may
+ contain complex backslash sequences, as well as support for the bitwise
+ operator (e.g. pipe symbol) inside of expression sections distinct
+ from the Mako "filter" operator, provided the operator is enclosed
+ within parentheses or brackets. Pull request courtesy Daniel Martin.
+
+ .. change::
+ :tags: feature
+ :pullreq: bitbucket:16
+
+ Added new method :meth:`.Template.list_defs`. Pull request courtesy
+ Jonathan Vanasco.
+
+.. changelog::
:version: 1.0.3
:released: Tue Oct 27 2015
diff --git a/mako/__init__.py b/mako/__init__.py
index 74526ec..1360163 100644
--- a/mako/__init__.py
+++ b/mako/__init__.py
@@ -1,8 +1,8 @@
# mako/__init__.py
-# Copyright (C) 2006-2015 the Mako authors and contributors <see AUTHORS file>
+# Copyright (C) 2006-2016 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
-__version__ = '1.0.3'
+__version__ = '1.0.4'
diff --git a/mako/_ast_util.py b/mako/_ast_util.py
index cc298d5..8d19b0d 100644
--- a/mako/_ast_util.py
+++ b/mako/_ast_util.py
@@ -1,5 +1,5 @@
# mako/_ast_util.py
-# Copyright (C) 2006-2015 the Mako authors and contributors <see AUTHORS file>
+# Copyright (C) 2006-2016 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
diff --git a/mako/ast.py b/mako/ast.py
index c55b29c..8d2d150 100644
--- a/mako/ast.py
+++ b/mako/ast.py
@@ -1,5 +1,5 @@
# mako/ast.py
-# Copyright (C) 2006-2015 the Mako authors and contributors <see AUTHORS file>
+# Copyright (C) 2006-2016 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
diff --git a/mako/cache.py b/mako/cache.py
index c7aabd2..94f3870 100644
--- a/mako/cache.py
+++ b/mako/cache.py
@@ -1,5 +1,5 @@
# mako/cache.py
-# Copyright (C) 2006-2015 the Mako authors and contributors <see AUTHORS file>
+# Copyright (C) 2006-2016 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
diff --git a/mako/cmd.py b/mako/cmd.py
index 50d47fc..dd1f833 100755
--- a/mako/cmd.py
+++ b/mako/cmd.py
@@ -1,5 +1,5 @@
# mako/cmd.py
-# Copyright (C) 2006-2015 the Mako authors and contributors <see AUTHORS file>
+# Copyright (C) 2006-2016 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
diff --git a/mako/codegen.py b/mako/codegen.py
index bf86d79..d4ecbe8 100644
--- a/mako/codegen.py
+++ b/mako/codegen.py
@@ -1,5 +1,5 @@
# mako/codegen.py
-# Copyright (C) 2006-2015 the Mako authors and contributors <see AUTHORS file>
+# Copyright (C) 2006-2016 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
diff --git a/mako/compat.py b/mako/compat.py
index db22b99..a2ab243 100644
--- a/mako/compat.py
+++ b/mako/compat.py
@@ -5,6 +5,7 @@ py3k = sys.version_info >= (3, 0)
py33 = sys.version_info >= (3, 3)
py2k = sys.version_info < (3,)
py26 = sys.version_info >= (2, 6)
+py27 = sys.version_info >= (2, 7)
jython = sys.platform.startswith('java')
win32 = sys.platform.startswith('win')
pypy = hasattr(sys, 'pypy_version_info')
diff --git a/mako/exceptions.py b/mako/exceptions.py
index 84d2297..cb6fb3f 100644
--- a/mako/exceptions.py
+++ b/mako/exceptions.py
@@ -1,5 +1,5 @@
# mako/exceptions.py
-# Copyright (C) 2006-2015 the Mako authors and contributors <see AUTHORS file>
+# Copyright (C) 2006-2016 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
diff --git a/mako/ext/autohandler.py b/mako/ext/autohandler.py
index 9ee780a..9d1c911 100644
--- a/mako/ext/autohandler.py
+++ b/mako/ext/autohandler.py
@@ -1,5 +1,5 @@
# ext/autohandler.py
-# Copyright (C) 2006-2015 the Mako authors and contributors <see AUTHORS file>
+# Copyright (C) 2006-2016 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
diff --git a/mako/ext/babelplugin.py b/mako/ext/babelplugin.py
index 53d62ba..0b5e84f 100644
--- a/mako/ext/babelplugin.py
+++ b/mako/ext/babelplugin.py
@@ -1,5 +1,5 @@
# ext/babelplugin.py
-# Copyright (C) 2006-2015 the Mako authors and contributors <see AUTHORS file>
+# Copyright (C) 2006-2016 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
diff --git a/mako/ext/preprocessors.py b/mako/ext/preprocessors.py
index 5624f70..9b700d1 100644
--- a/mako/ext/preprocessors.py
+++ b/mako/ext/preprocessors.py
@@ -1,5 +1,5 @@
# ext/preprocessors.py
-# Copyright (C) 2006-2015 the Mako authors and contributors <see AUTHORS file>
+# Copyright (C) 2006-2016 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
diff --git a/mako/ext/pygmentplugin.py b/mako/ext/pygmentplugin.py
index 1121c5d..4057caa 100644
--- a/mako/ext/pygmentplugin.py
+++ b/mako/ext/pygmentplugin.py
@@ -1,5 +1,5 @@
# ext/pygmentplugin.py
-# Copyright (C) 2006-2015 the Mako authors and contributors <see AUTHORS file>
+# Copyright (C) 2006-2016 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
diff --git a/mako/ext/turbogears.py b/mako/ext/turbogears.py
index 2e7d039..eaa2d78 100644
--- a/mako/ext/turbogears.py
+++ b/mako/ext/turbogears.py
@@ -1,5 +1,5 @@
# ext/turbogears.py
-# Copyright (C) 2006-2015 the Mako authors and contributors <see AUTHORS file>
+# Copyright (C) 2006-2016 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
diff --git a/mako/filters.py b/mako/filters.py
index 525aeb8..c082690 100644
--- a/mako/filters.py
+++ b/mako/filters.py
@@ -1,5 +1,5 @@
# mako/filters.py
-# Copyright (C) 2006-2015 the Mako authors and contributors <see AUTHORS file>
+# Copyright (C) 2006-2016 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
diff --git a/mako/lexer.py b/mako/lexer.py
index 2fa08e4..cf4187f 100644
--- a/mako/lexer.py
+++ b/mako/lexer.py
@@ -1,5 +1,5 @@
# mako/lexer.py
-# Copyright (C) 2006-2015 the Mako authors and contributors <see AUTHORS file>
+# Copyright (C) 2006-2016 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
@@ -95,31 +95,37 @@ class Lexer(object):
# (match and "TRUE" or "FALSE")
return match
- def parse_until_text(self, *text):
+ def parse_until_text(self, watch_nesting, *text):
startpos = self.match_position
text_re = r'|'.join(text)
brace_level = 0
+ paren_level = 0
+ bracket_level = 0
while True:
match = self.match(r'#.*\n')
if match:
continue
- match = self.match(r'(\"\"\"|\'\'\'|\"|\')((?<!\\)\\\1|.)*?\1',
+ match = self.match(r'(\"\"\"|\'\'\'|\"|\')[^\\]*?(\\.[^\\]*?)*\1',
re.S)
if match:
continue
match = self.match(r'(%s)' % text_re)
- if match:
- if match.group(1) == '}' and brace_level > 0:
- brace_level -= 1
- continue
+ if match and not (watch_nesting
+ and (brace_level > 0 or paren_level > 0
+ or bracket_level > 0)):
return \
self.text[startpos:
self.match_position - len(match.group(1))],\
match.group(1)
- match = self.match(r"(.*?)(?=\"|\'|#|%s)" % text_re, re.S)
+ elif not match:
+ match = self.match(r"(.*?)(?=\"|\'|#|%s)" % text_re, re.S)
if match:
brace_level += match.group(1).count('{')
brace_level -= match.group(1).count('}')
+ paren_level += match.group(1).count('(')
+ paren_level -= match.group(1).count(')')
+ bracket_level += match.group(1).count('[')
+ bracket_level -= match.group(1).count(']')
continue
raise exceptions.SyntaxException(
"Expected: %s" %
@@ -368,7 +374,7 @@ class Lexer(object):
match = self.match(r"<%(!)?")
if match:
line, pos = self.matched_lineno, self.matched_charpos
- text, end = self.parse_until_text(r'%>')
+ text, end = self.parse_until_text(False, r'%>')
# the trailing newline helps
# compiler.parse() not complain about indentation
text = adjust_whitespace(text) + "\n"
@@ -384,9 +390,9 @@ class Lexer(object):
match = self.match(r"\${")
if match:
line, pos = self.matched_lineno, self.matched_charpos
- text, end = self.parse_until_text(r'\|', r'}')
+ text, end = self.parse_until_text(True, r'\|', r'}')
if end == '|':
- escapes, end = self.parse_until_text(r'}')
+ escapes, end = self.parse_until_text(True, r'}')
else:
escapes = ""
text = text.replace('\r\n', '\n')
diff --git a/mako/lookup.py b/mako/lookup.py
index e6dff9d..a9c5bb2 100644
--- a/mako/lookup.py
+++ b/mako/lookup.py
@@ -1,5 +1,5 @@
# mako/lookup.py
-# Copyright (C) 2006-2015 the Mako authors and contributors <see AUTHORS file>
+# Copyright (C) 2006-2016 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
diff --git a/mako/parsetree.py b/mako/parsetree.py
index e7af4bc..879882e 100644
--- a/mako/parsetree.py
+++ b/mako/parsetree.py
@@ -1,5 +1,5 @@
# mako/parsetree.py
-# Copyright (C) 2006-2015 the Mako authors and contributors <see AUTHORS file>
+# Copyright (C) 2006-2016 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
diff --git a/mako/pygen.py b/mako/pygen.py
index 5d87bbd..8514e02 100644
--- a/mako/pygen.py
+++ b/mako/pygen.py
@@ -1,5 +1,5 @@
# mako/pygen.py
-# Copyright (C) 2006-2015 the Mako authors and contributors <see AUTHORS file>
+# Copyright (C) 2006-2016 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
diff --git a/mako/pyparser.py b/mako/pyparser.py
index 96e5335..15d0da6 100644
--- a/mako/pyparser.py
+++ b/mako/pyparser.py
@@ -1,5 +1,5 @@
# mako/pyparser.py
-# Copyright (C) 2006-2015 the Mako authors and contributors <see AUTHORS file>
+# Copyright (C) 2006-2016 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
diff --git a/mako/runtime.py b/mako/runtime.py
index 8d2f4a9..5c40381 100644
--- a/mako/runtime.py
+++ b/mako/runtime.py
@@ -1,5 +1,5 @@
# mako/runtime.py
-# Copyright (C) 2006-2015 the Mako authors and contributors <see AUTHORS file>
+# Copyright (C) 2006-2016 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
diff --git a/mako/template.py b/mako/template.py
index afb679a..bacbc13 100644
--- a/mako/template.py
+++ b/mako/template.py
@@ -1,5 +1,5 @@
# mako/template.py
-# Copyright (C) 2006-2015 the Mako authors and contributors <see AUTHORS file>
+# Copyright (C) 2006-2016 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
@@ -475,6 +475,14 @@ class Template(object):
return DefTemplate(self, getattr(self.module, "render_%s" % name))
+ def list_defs(self):
+ """return a list of defs in the template.
+
+ .. versionadded:: 1.0.4
+
+ """
+ return [i[7:] for i in dir(self.module) if i[:7] == 'render_']
+
def _get_def_callable(self, name):
return getattr(self.module, "render_%s" % name)
diff --git a/mako/util.py b/mako/util.py
index c7dad65..2f089ff 100644
--- a/mako/util.py
+++ b/mako/util.py
@@ -1,5 +1,5 @@
# mako/util.py
-# Copyright (C) 2006-2015 the Mako authors and contributors <see AUTHORS file>
+# Copyright (C) 2006-2016 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
diff --git a/setup.py b/setup.py
index 56754aa..5b64d3f 100644
--- a/setup.py
+++ b/setup.py
@@ -1,4 +1,5 @@
from setuptools import setup, find_packages
+from setuptools.command.test import test as TestCommand
import os
import re
import sys
@@ -13,8 +14,8 @@ if sys.version_info < (2, 6):
raise Exception("Mako requires Python 2.6 or higher.")
markupsafe_installs = (
- sys.version_info >= (2, 6) and sys.version_info < (3, 0)
- ) or sys.version_info >= (3, 3)
+ sys.version_info >= (2, 6) and sys.version_info < (3, 0)
+) or sys.version_info >= (3, 3)
install_requires = []
@@ -26,6 +27,26 @@ try:
except ImportError:
install_requires.append('argparse')
+
+class PyTest(TestCommand):
+ user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")]
+
+ def initialize_options(self):
+ TestCommand.initialize_options(self)
+ self.pytest_args = []
+
+ def finalize_options(self):
+ TestCommand.finalize_options(self)
+ self.test_args = []
+ self.test_suite = True
+
+ def run_tests(self):
+ # import here, cause outside the eggs aren't loaded
+ import pytest
+ errno = pytest.main(self.pytest_args)
+ sys.exit(errno)
+
+
setup(name='Mako',
version=VERSION,
description="A super-fast templating language that borrows the \
@@ -47,8 +68,8 @@ setup(name='Mako',
url='http://www.makotemplates.org/',
license='MIT',
packages=find_packages('.', exclude=['examples*', 'test*']),
- tests_require=['nose >= 0.11', 'mock'],
- test_suite="nose.collector",
+ tests_require=['pytest', 'mock'],
+ cmdclass={'test': PyTest},
zip_safe=False,
install_requires=install_requires,
extras_require={},
diff --git a/test/test_cache.py b/test/test_cache.py
index f37042f..990a088 100644
--- a/test/test_cache.py
+++ b/test/test_cache.py
@@ -5,7 +5,7 @@ import time
from test.util import result_lines
from test import TemplateTest, module_base
from test import eq_, SkipTest
-
+from mako.compat import py27
from mako.ext import beaker_cache
@@ -603,6 +603,8 @@ class BeakerCacheTest(RealBackendTest, CacheTest):
def setUp(self):
if not beaker_cache.has_beaker:
raise SkipTest("Beaker is required for these tests.")
+ if not py27:
+ raise SkipTest("newer beakers not working w/ py26")
def _install_mock_cache(self, template, implname=None):
template.cache_args['manager'] = self._regions()
diff --git a/test/test_def.py b/test/test_def.py
index 8b32561..19142c8 100644
--- a/test/test_def.py
+++ b/test/test_def.py
@@ -123,6 +123,41 @@ class DefTest(TemplateTest):
filters=flatten_result,
template_args={'q': 5, 'zq': 'test'})
+ def test_def_operations(self):
+ """test get/list/has def"""
+
+ template = Template("""
+
+ this is the body
+
+ <%def name="a()">
+ this is a
+ </%def>
+
+ <%def name="b(x, y)">
+ this is b, ${x} ${y}
+ </%def>
+
+ """)
+
+ assert template.get_def("a")
+ assert template.get_def("b")
+ assert_raises(AttributeError,
+ template.get_def,
+ ("c")
+ )
+
+ assert template.has_def("a")
+ assert template.has_def("b")
+ assert not template.has_def("c")
+
+ defs = template.list_defs()
+ assert "a" in defs
+ assert "b" in defs
+ assert "body" in defs
+ assert "c" not in defs
+
+
class ScopeTest(TemplateTest):
"""test scoping rules. The key is, enclosing
scope always takes precedence over contextual scope."""
diff --git a/test/test_exceptions.py b/test/test_exceptions.py
index 3330a1f..8321b25 100644
--- a/test/test_exceptions.py
+++ b/test/test_exceptions.py
@@ -91,9 +91,7 @@ ${u'привет'}
assert "".encode(sys.getdefaultencoding(),
'htmlentityreplace') in html_error
else:
- assert '<pre>3</pre></div></td><td class="code">'\
- '<div class="syntax-highlighted"><pre><span '\
- 'class="cp">${</span><span class="s">u''\
+ assert 'u''\
'привет'\
''</span><span class="cp">}</span>'.encode(
sys.getdefaultencoding(),
@@ -188,12 +186,8 @@ ${foobar}
${self.body()}
""")
- assert '<div class="sourceline"><table class="syntax-highlightedtable">'\
- '<tr><td class="linenos"><div class="linenodiv"><pre>3</pre>'\
- '</div></td><td class="code"><div class="syntax-highlighted">'\
- '<pre><span class="err">$</span><span class="p">{</span>'\
- '<span class="n">foobar</span><span class="p">}</span>' in \
- result_lines(l.get_template("foo.html").render_unicode())
+ assert '<div class="sourceline"><table class="syntax-highlightedtable">' in \
+ l.get_template("foo.html").render_unicode()
@requires_no_pygments_exceptions
def test_format_exceptions_no_pygments(self):
@@ -223,24 +217,12 @@ ${foobar}
l.put_string("foo.html", """# -*- coding: utf-8 -*-\n${u'привет' + foobar}""")
if compat.py3k:
- assert '<table class="error syntax-highlightedtable"><tr><td '\
- 'class="linenos"><div class="linenodiv"><pre>2</pre>'\
- '</div></td><td class="code"><div class="error '\
- 'syntax-highlighted"><pre><span class="cp">${</span>'\
- '<span class="s">'привет'</span> <span class="o">+</span> '\
- '<span class="n">foobar</span><span class="cp">}</span>'\
- '<span class="x"></span>' in \
- result_lines(l.get_template("foo.html").render().decode('utf-8'))
+ assert ''привет'</span>' in \
+ l.get_template("foo.html").render().decode('utf-8')
else:
- assert '<table class="error syntax-highlightedtable"><tr><td '\
- 'class="linenos"><div class="linenodiv"><pre>2</pre>'\
- '</div></td><td class="code"><div class="error '\
- 'syntax-highlighted"><pre><span class="cp">${</span>'\
- '<span class="s">u'прив'\
- 'ет'</span> <span class="o">+</span> '\
- '<span class="n">foobar</span><span class="cp">}</span>'\
- '<span class="x"></span>' in \
- result_lines(l.get_template("foo.html").render().decode('utf-8'))
+ assert 'u'прив'\
+ 'ет'</span>' in \
+ l.get_template("foo.html").render().decode('utf-8')
@requires_no_pygments_exceptions
def test_utf8_format_exceptions_no_pygments(self):
diff --git a/test/test_lexer.py b/test/test_lexer.py
index 3e97bef..06ebb05 100644
--- a/test/test_lexer.py
+++ b/test/test_lexer.py
@@ -477,9 +477,10 @@ more text
])
)
- template = """
+ template = r"""
${hello + '''heres '{|}' text | | }''' | escape1}
+ ${'Tricky string: ' + '\\\"\\\'|\\'}
"""
nodes = Lexer(template).parse()
self._compare(
@@ -488,7 +489,10 @@ more text
Text('\n\n ', (1, 1)),
Expression("hello + '''heres '{|}' text | | }''' ",
['escape1'], (3, 13)),
- Text('\n ', (3, 62))
+ Text('\n ', (3, 62)),
+ Expression(r"""'Tricky string: ' + '\\\"\\\'|\\'""",
+ [], (4, 13)),
+ Text('\n ', (4, 49))
])
)
@@ -587,6 +591,15 @@ print('''
Expression(" {'key': 'value'} ", [], (1, 8)),
Text(' after', (1, 29))]))
+ def test_tricky_code_6(self):
+ template = \
+ """before ${ (0x5302 | 0x0400) } after"""
+ nodes = Lexer(template).parse()
+ self._compare(nodes, TemplateNode({},
+ [Text('before ', (1, 1)),
+ Expression(" (0x5302 | 0x0400) ", [], (1, 8)),
+ Text(' after', (1, 30))]))
+
def test_control_lines(self):
template = \
"""
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/mako.git
More information about the Python-modules-commits
mailing list