Merge branch '2.7-maintenance'
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Armin Ronacher · committed by Armin Ronacher · parents 4c7b51b, 3d82fc3 · Browse files · 4 files·+42 added−3 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+42 added−3 removed
- other:+42 added−3 removed
Provenance
- Commit
d65f40f- Tree
3353b0a- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent 1
4c7b51b- Parent 2
3d82fc3
4 files changed+42 added−3 removed
modified:jinja2/testsuite/__init__.py+2 added-1 removed
121 unmodified lines122 123 def suite():124 from jinja2.testsuite import ext, filters, tests, core_tags, \125 loader, inheritance, imports, lexnparse, security, api, \126- regression, debug, utils, doctests126+ regression, debug, utils, bytecode_cache, doctests127 suite = unittest.TestSuite()128 suite.addTest(ext.suite())129 suite.addTest(filters.suite())130 suite.addTest(tests.suite())6 unmodified lines137 suite.addTest(api.suite())138 suite.addTest(regression.suite())139 suite.addTest(debug.suite())140 suite.addTest(utils.suite())141+ suite.addTest(bytecode_cache.suite())142 143 # doctests will not run on python 3 currently. Too many issues144 # with that, do not test that on that platform.145 if PY2:11 unmodified linesadded:jinja2/testsuite/bytecode_cache.py+37 added
1+# -*- coding: utf-8 -*-2+"""3+ jinja2.testsuite.bytecode_cache4+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~5+6+ Test bytecode caching7+8+ :copyright: (c) 2010 by the Jinja Team.9+ :license: BSD, see LICENSE for more details.10+"""11+import unittest12+13+from jinja2.testsuite import JinjaTestCase, package_loader14+15+from jinja2 import Environment16+from jinja2.bccache import FileSystemBytecodeCache17+from jinja2.exceptions import TemplateNotFound18+19+bytecode_cache = FileSystemBytecodeCache()20+env = Environment(21+ loader=package_loader,22+ bytecode_cache=bytecode_cache,23+)24+25+26+class ByteCodeCacheTestCase(JinjaTestCase):27+28+ def test_simple(self):29+ tmpl = env.get_template('test.html')30+ assert tmpl.render().strip() == 'BAR'31+ self.assert_raises(TemplateNotFound, env.get_template, 'missing.html')32+33+34+def suite():35+ suite = unittest.TestSuite()36+ suite.addTest(unittest.makeSuite(ByteCodeCacheTestCase))37+ return suitemodified:jinja2/bccache.py+2 added-2 removed
19 unmodified lines20 import tempfile21 import fnmatch22 from hashlib import sha123 from jinja2.utils import open_if_exists24-from jinja2._compat import BytesIO, pickle, PY224+from jinja2._compat import BytesIO, pickle, PY2, text_type25 26 27 # marshal works better on 3.x, one hack less required28 if not PY2:130 unmodified lines159 """Returns the unique hash key for this template name."""160 hash = sha1(name.encode('utf-8'))161 if filename is not None:162 filename = '|' + filename163- if isinstance(filename, unicode):163+ if isinstance(filename, text_type):164 filename = filename.encode('utf-8')165 hash.update(filename)166 return hash.hexdigest()167 144 unmodified linesmodified:CHANGES+1 added
5 unmodified lines6 (bugfix release)7 8 - Fixed a bug with ``call_filter`` not working properly on environment9 and context filters.10+- Fixed lack of Python 3 support for bytecode caches.11 12 Version 2.713 -----------14 (codename Translation, released on May 20th 2013)294 unmodified lines