Skip to content
Myr

[svn] added simple memcached loader test

Before adoption: this commit came in with the history the project adopted, so no landing records it.

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent db69d0a · Browse files · 3 files+36 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+36 added−0 removed

  • tests:+34 added−0 removed
  • other:+2 added−0 removed

3 files+36 added−0 removed

modified:jinja/loaders.py+2 added
664 unmodified lines
665 e = Environment(loader=DictLoader(dict(666 layout='...',667 index='{% extends 'layout' %}...'668 )))669670 This loader does not have any caching capabilities.671 """672673 def __init__(self, templates):674 self.templates = templates
52 unmodified lines
modified:tests/conftest.py+18 added
71 unmodified lines
72loader = GlobalLoader(globals())73simple_env = Environment(trim_blocks=True, friendly_traceback=False, loader=loader)747576class MemcacheClient(object):77 """78 Helper for the loader test.79 """8081 def __init__(self, hosts):82 self.cache = {}8384 def get(self, name):85 return self.cache.get(name)8687 def set(self, name, data, time):88 self.cache[name] = data8990sys.modules['memcache'] = memcache = type(sys)('memcache')91memcache.Client = MemcacheClient929394class Module(py.test.collect.Module):9596 def __init__(self, *args, **kwargs):97 self.env = simple_env
35 unmodified lines
modified:tests/test_loaders.py+16 added
19 unmodified lines
20package_loader = loaders.PackageLoader('loaderres', 'templates')2122filesystem_loader = loaders.FileSystemLoader('loaderres/templates')2324memcached_loader = loaders.MemcachedFileSystemLoader('loaderres/templates')2526function_loader = loaders.FunctionLoader({'justfunction.html': 'FOO'}.get)2728choice_loader = loaders.ChoiceLoader([dict_loader, package_loader])29
39 unmodified lines
69 else:70 raise AssertionError('expected template exception')717273def test_memcached_loader():74 env = Environment(loader=memcached_loader)75 tmpl = env.get_template('test.html')76 assert tmpl.render().strip() == 'BAR'77 tmpl = env.get_template('foo/test.html')78 assert tmpl.render().strip() == 'FOO'79 try:80 env.get_template('missing.html')81 except TemplateNotFound:82 pass83 else:84 raise AssertionError('expected template exception')858687def test_choice_loader():88 env = Environment(loader=choice_loader)89 tmpl = env.get_template('justdict.html')90 assert tmpl.render().strip() == 'FOO'
83 unmodified lines