Improved test invokation. Picks up doctests within Jinja now, changed
Before adoption: this commit came in with the history the project adopted, so no landing records it.
doctests that just show usage that would not work on their own so that they are standard code blocks now and do not disturb testing. --HG-- branch : trunk
authored by Armin Ronacher · committed by Armin Ronacher · parent 92622e9 · Browse files · 5 files·+18 added−14 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+18 added−14 removed
- tests:+5 added−4 removed
- other:+13 added−10 removed
Provenance
- Commit
8e64adf- Tree
9a81344- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent
92622e9
5 files changed+18 added−14 removed
modified:jinja2/loaders.py+9 added-9 removed
162 unmodified lines163 164 class PackageLoader(BaseLoader):165 """Load templates from python eggs or packages. It is constructed with166 the name of the python package and the path to the templates in that167- package:167+ package::168 169- >>> loader = PackageLoader('mypackage', 'views')169+ loader = PackageLoader('mypackage', 'views')170 171 If the package path is not given, ``'templates'`` is assumed.172 173 Per default the template encoding is ``'utf-8'`` which can be changed58 unmodified lines232 an unicode string with the template source, a tuple in the form ``(source,233 filename, uptodatefunc)`` or `None` if the template does not exist.234 235 >>> def load_template(name):236- ... if name == 'index.html'236+ ... if name == 'index.html':237 ... return '...'238 ...239 >>> loader = FunctionLoader(load_template)240 18 unmodified lines259 class PrefixLoader(BaseLoader):260 """A loader that is passed a dict of loaders where each loader is bound261 to a prefix. The prefix is delimited from the template by a slash per262 default, which can be changed by setting the `delimiter` argument to263- something else.263+ something else::264 265- >>> loader = PrefixLoader({266- ... 'app1': PackageLoader('mypackage.app1'),267- ... 'app2': PackageLoader('mypackage.app2')268- ... })265+ loader = PrefixLoader({266+ 'app1': PackageLoader('mypackage.app1'),267+ 'app2': PackageLoader('mypackage.app2')268+ })269 270 By loading ``'app1/index.html'`` the file from the app1 package is loaded,271 by loading ``'app2/index.html'`` the file from the second.272 """17 unmodified lines290 is tried.291 292 >>> loader = ChoiceLoader([293 ... FileSystemLoader('/path/to/user/templates'),294- ... PackageLoader('mypackage')294+ ... FileSystemLoader('/path/to/system/templates')295 ... ])296 297 This is useful if you want to allow users to override builtin templates298 from a different location.12 unmodified linesmodified:jinja2/tests.py+3 added
9 unmodified lines10 """11 import re12 from jinja2.runtime import Undefined13 14+# nose, nothing here to test15+__test__ = False16 17+18 number_re = re.compile(r'^-?\d+(\.\d+)?$')19 regex_type = type(number_re)20 21 125 unmodified linesmodified:tests/test_debug.py+3 added-3 removed
30 unmodified lines31 '''32 >>> tmpl = env.get_template('syntaxerror.html')33 Traceback (most recent call last):34 ...35-TemplateSyntaxError: unknown tag 'endif'36- File "loaderres/templates\\syntaxerror.html", line 437- {% endif %}35+ File "tests/loaderres/templates/syntaxerror.html", line 4, in template36+ {% endif %}37+TemplateSyntaxError: Encountered unknown tag 'endif'. Jinja was looking for the following tags: 'endfor' or 'else'. The innermost block that needs to be closed is 'for'.38 '''39 40 41 def test_regular_syntax_error():10 unmodified linesmodified:tests/test_loaders.py+2 added-1 removed
5 unmodified lines6 :copyright: (c) 2009 by the Jinja Team.7 :license: BSD, see LICENSE for more details.8 """9 10+import os11 import time12 import tempfile13 from jinja2 import Environment, loaders14 from jinja2.loaders import split_template_path5 unmodified lines20 dict_loader = loaders.DictLoader({21 'justdict.html': 'FOO'22 })23 package_loader = loaders.PackageLoader('loaderres', 'templates')23-filesystem_loader = loaders.FileSystemLoader('loaderres/templates')24+filesystem_loader = loaders.FileSystemLoader('tests/loaderres/templates')25 function_loader = loaders.FunctionLoader({'justfunction.html': 'FOO'}.get)26 choice_loader = loaders.ChoiceLoader([dict_loader, package_loader])27 prefix_loader = loaders.PrefixLoader({28 'a': filesystem_loader,84 unmodified linesmodified:Makefile+1 added-1 removed
1 test:2- cd tests; nosetests -v2+ nosetests --with-doctest jinja2 tests3 4 2to3:5 rm -rf py3k6 mkdir py3k6 unmodified lines