Got rid of py.testisms.
--HG--
branch : trunk
diff --git a/tests/test_syntax.py b/tests/test_syntax.py
index 2e8877a..759af6a 100644
--- a/tests/test_syntax.py
+++ b/tests/test_syntax.py
@@ -6,14 +6,12 @@
:copyright: (c) 2009 by the Jinja Team.
:license: BSD, see LICENSE for more details.
"""
-from jinja2 import Environment, DictLoader
+from jinja2 import Environment
from jinja2.exceptions import TemplateSyntaxError, UndefinedError
-import conftest
-if conftest.NOSE:
- from nose.tools import assert_raises as raises
-else:
- from py.test import raises
+from nose.tools import assert_raises
+
+env = Environment()
CALL = '''{{ foo('a', c='d', e='f', *['b'], **{'g': 'h'}) }}'''
@@ -47,102 +45,101 @@
def test_call():
- from jinja2 import Environment
env = Environment()
env.globals['foo'] = lambda a, b, c, e, g: a + b + c + e + g
tmpl = env.from_string(CALL)
assert tmpl.render() == 'abdfh'
-def test_slicing(env):
+def test_slicing():
tmpl = env.from_string(SLICING)
assert tmpl.render() == '[1, 2, 3]|[3, 2, 1]'
-def test_attr(env):
+def test_attr():
tmpl = env.from_string(ATTR)
assert tmpl.render(foo={'bar': 42}) == '42|42'
-def test_subscript(env):
+def test_subscript():
tmpl = env.from_string(SUBSCRIPT)
assert tmpl.render(foo=[0, 1, 2]) == '0|2'
-def test_tuple(env):
+def test_tuple():
tmpl = env.from_string(TUPLE)
assert tmpl.render() == '()|(1,)|(1, 2)'
-def test_math(env):
+def test_math():
tmpl = env.from_string(MATH)
assert tmpl.render() == '1.5|8'
-def test_div(env):
+def test_div():
tmpl = env.from_string(DIV)
assert tmpl.render() == '1|1.5|1'
-def test_unary(env):
+def test_unary():
tmpl = env.from_string(UNARY)
assert tmpl.render() == '3|-3'
-def test_concat(env):
+def test_concat():
tmpl = env.from_string(CONCAT)
assert tmpl.render() == '[1, 2]foo'
-def test_compare(env):
+def test_compare():
tmpl = env.from_string(COMPARE)
assert tmpl.render() == 'True|True|True|True|True'
-def test_inop(env):
+def test_inop():
tmpl = env.from_string(INOP)
assert tmpl.render() == 'True|False'
-def test_literals(env):
+def test_literals():
tmpl = env.from_string(LITERALS)
assert tmpl.render().lower() == '[]|{}|()'
-def test_bool(env):
+def test_bool():
tmpl = env.from_string(BOOL)
assert tmpl.render() == 'False|True|True'
-def test_grouping(env):
+def test_grouping():
tmpl = env.from_string(GROUPING)
assert tmpl.render() == 'False'
-def test_django_attr(env):
+def test_django_attr():
tmpl = env.from_string(DJANGOATTR)
assert tmpl.render() == '1|1'
-def test_conditional_expression(env):
+def test_conditional_expression():
tmpl = env.from_string(CONDEXPR)
assert tmpl.render() == '0'
-def test_short_conditional_expression(env):
+def test_short_conditional_expression():
tmpl = env.from_string('<{{ 1 if false }}>')
assert tmpl.render() == '<>'
tmpl = env.from_string('<{{ (1 if false).bar }}>')
- raises(UndefinedError, tmpl.render)
+ assert_raises(UndefinedError, tmpl.render)
-def test_filter_priority(env):
+def test_filter_priority():
tmpl = env.from_string(FILTERPRIORITY)
assert tmpl.render() == 'FOOBAR'
-def test_function_calls(env):
+def test_function_calls():
tests = [
(True, '*foo, bar'),
(True, '*foo, *bar'),
@@ -157,28 +154,28 @@
]
for should_fail, sig in tests:
if should_fail:
- raises(TemplateSyntaxError, env.from_string, '{{ foo(%s) }}' % sig)
+ assert_raises(TemplateSyntaxError, env.from_string, '{{ foo(%s) }}' % sig)
else:
env.from_string('foo(%s)' % sig)
-def test_tuple_expr(env):
+def test_tuple_expr():
for tmpl in TUPLETEMPLATES:
print tmpl
assert env.from_string(tmpl)
-def test_trailing_comma(env):
+def test_trailing_comma():
tmpl = env.from_string(TRAILINGCOMMA)
assert tmpl.render().lower() == '(1, 2)|[1, 2]|{1: 2}'
-def test_block_end_name(env):
+def test_block_end_name():
env.from_string('{% block foo %}...{% endblock foo %}')
- raises(TemplateSyntaxError, env.from_string, '{% block x %}{% endblock y %}')
+ assert_raises(TemplateSyntaxError, env.from_string, '{% block x %}{% endblock y %}')
-def test_contant_casing(env):
+def test_contant_casing():
for const in True, False, None:
tmpl = env.from_string('{{ %s }}|{{ %s }}|{{ %s }}' % (
str(const), str(const).lower(), str(const).upper()
@@ -186,23 +183,23 @@
assert tmpl.render() == '%s|%s|' % (const, const)
-def test_test_chaining(env):
- raises(TemplateSyntaxError, env.from_string, '{{ foo is string is sequence }}')
+def test_test_chaining():
+ assert_raises(TemplateSyntaxError, env.from_string, '{{ foo is string is sequence }}')
env.from_string('{{ 42 is string or 42 is number }}').render() == 'True'
-def test_string_concatenation(env):
+def test_string_concatenation():
tmpl = env.from_string('{{ "foo" "bar" "baz" }}')
assert tmpl.render() == 'foobarbaz'
-def test_notin(env):
+def test_notin():
bar = xrange(100)
tmpl = env.from_string('''{{ not 42 in bar }}''')
assert tmpl.render(bar=bar) == unicode(not 42 in bar)
-def test_implicit_subscribed_tuple(env):
+def test_implicit_subscribed_tuple():
class Foo(object):
def __getitem__(self, x):
return x