"""
import re
from random import choice
-from operator import itemgetter
+try:
+ from operator import itemgetter
+except ImportError:
+ itemgetter = lambda a: lambda b: b[a]
from urllib import urlencode, quote
from jinja.utils import urlize, escape, reversed, sorted, groupby, \
get_attribute, pformat
r'|"([^"\\]*(?:\\.[^"\\]*)*)")(?ms)')
integer_re = re.compile(r'\d+')
float_re = re.compile(r'\d+\.\d+')
-regex_re = re.compile(r'@/([^/\\]*(?:\\.[^/\\]*)*)*/[a-z]*(?ms)')
+regex_re = re.compile(r'\@/([^/\\]*(?:\\.[^/\\]*)*)*/[a-z]*(?ms)')
# set of used keywords
CONDEXPR = '''{{ 0 if true else 1 }}'''
DJANGOATTR = '''{{ [1, 2, 3].0 }}'''
FILTERPRIORITY = '''{{ "foo"|upper + "bar"|upper }}'''
-REGEX = '''{{ @/\S+/.findall('foo bar baz') }}'''
+REGEX = r'''{{ @/\S+/.findall('foo bar baz') }}'''
TUPLETEMPLATES = [
'{{ () }}',
'{{ (1, 2) }}',
def test_literals(env):
tmpl = env.from_string(LITERALS)
- assert tmpl.render() == '[]|{}|()||set([])'
+ assert tmpl.render().lower() == '[]|{}|()||set([])'
def test_bool(env):
def test_trailing_comma(env):
tmpl = env.from_string(TRAILINGCOMMA)
- assert tmpl.render() == '(1, 2)|[1, 2]|{1: 2}|set([1, 2])'
+ assert tmpl.render().lower() == '(1, 2)|[1, 2]|{1: 2}|set([1, 2])'
def test_extends_position():