Improved test invokation. Picks up doctests within Jinja now, changed
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
diff --git a/Makefile b/Makefile
index 85ed64d..124b253 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
test:
- cd tests; nosetests -v
+ nosetests --with-doctest jinja2 tests
2to3:
rm -rf py3k
diff --git a/jinja2/loaders.py b/jinja2/loaders.py
index 5d5723d..7dda2ae 100644
--- a/jinja2/loaders.py
+++ b/jinja2/loaders.py
@@ -164,9 +164,9 @@
class PackageLoader(BaseLoader):
"""Load templates from python eggs or packages. It is constructed with
the name of the python package and the path to the templates in that
- package:
+ package::
- >>> loader = PackageLoader('mypackage', 'views')
+ loader = PackageLoader('mypackage', 'views')
If the package path is not given, ``'templates'`` is assumed.
@@ -233,7 +233,7 @@
filename, uptodatefunc)`` or `None` if the template does not exist.
>>> def load_template(name):
- ... if name == 'index.html'
+ ... if name == 'index.html':
... return '...'
...
>>> loader = FunctionLoader(load_template)
@@ -260,12 +260,12 @@
"""A loader that is passed a dict of loaders where each loader is bound
to a prefix. The prefix is delimited from the template by a slash per
default, which can be changed by setting the `delimiter` argument to
- something else.
+ something else::
- >>> loader = PrefixLoader({
- ... 'app1': PackageLoader('mypackage.app1'),
- ... 'app2': PackageLoader('mypackage.app2')
- ... })
+ loader = PrefixLoader({
+ 'app1': PackageLoader('mypackage.app1'),
+ 'app2': PackageLoader('mypackage.app2')
+ })
By loading ``'app1/index.html'`` the file from the app1 package is loaded,
by loading ``'app2/index.html'`` the file from the second.
@@ -291,7 +291,7 @@
>>> loader = ChoiceLoader([
... FileSystemLoader('/path/to/user/templates'),
- ... PackageLoader('mypackage')
+ ... FileSystemLoader('/path/to/system/templates')
... ])
This is useful if you want to allow users to override builtin templates
diff --git a/jinja2/tests.py b/jinja2/tests.py
index 2d72dcb..d257eca 100644
--- a/jinja2/tests.py
+++ b/jinja2/tests.py
@@ -11,6 +11,9 @@
import re
from jinja2.runtime import Undefined
+# nose, nothing here to test
+__test__ = False
+
number_re = re.compile(r'^-?\d+(\.\d+)?$')
regex_type = type(number_re)
diff --git a/tests/test_debug.py b/tests/test_debug.py
index d8e8a44..921b335 100644
--- a/tests/test_debug.py
+++ b/tests/test_debug.py
@@ -32,9 +32,9 @@
>>> tmpl = env.get_template('syntaxerror.html')
Traceback (most recent call last):
...
-TemplateSyntaxError: unknown tag 'endif'
- File "loaderres/templates\\syntaxerror.html", line 4
- {% endif %}
+ File "tests/loaderres/templates/syntaxerror.html", line 4, in template
+ {% endif %}
+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'.
'''
diff --git a/tests/test_loaders.py b/tests/test_loaders.py
index 17e6bf1..64193f3 100644
--- a/tests/test_loaders.py
+++ b/tests/test_loaders.py
@@ -7,6 +7,7 @@
:license: BSD, see LICENSE for more details.
"""
+import os
import time
import tempfile
from jinja2 import Environment, loaders
@@ -20,7 +21,7 @@
'justdict.html': 'FOO'
})
package_loader = loaders.PackageLoader('loaderres', 'templates')
-filesystem_loader = loaders.FileSystemLoader('loaderres/templates')
+filesystem_loader = loaders.FileSystemLoader('tests/loaderres/templates')
function_loader = loaders.FunctionLoader({'justfunction.html': 'FOO'}.get)
choice_loader = loaders.ChoiceLoader([dict_loader, package_loader])
prefix_loader = loaders.PrefixLoader({