aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/Jinja2/py2/tests/test_idtracking.py
diff options
context:
space:
mode:
authorfloatdrop <floatdrop@yandex-team.ru>2022-02-10 16:47:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:15 +0300
commite63b84f1d39557d9e46ac380b1f388271894293c (patch)
tree338cdaff3fb027e030b847db66df06019a0e3149 /contrib/python/Jinja2/py2/tests/test_idtracking.py
parentf60febb7ea449535e7b073c386c7ff0539637fc0 (diff)
downloadydb-e63b84f1d39557d9e46ac380b1f388271894293c.tar.gz
Restoring authorship annotation for <floatdrop@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/python/Jinja2/py2/tests/test_idtracking.py')
-rw-r--r--contrib/python/Jinja2/py2/tests/test_idtracking.py168
1 files changed, 84 insertions, 84 deletions
diff --git a/contrib/python/Jinja2/py2/tests/test_idtracking.py b/contrib/python/Jinja2/py2/tests/test_idtracking.py
index 4c79ee6c47..2cb8d2dc65 100644
--- a/contrib/python/Jinja2/py2/tests/test_idtracking.py
+++ b/contrib/python/Jinja2/py2/tests/test_idtracking.py
@@ -1,9 +1,9 @@
-from jinja2 import nodes
-from jinja2.idtracking import symbols_for_node
-
-
-def test_basics():
- for_loop = nodes.For(
+from jinja2 import nodes
+from jinja2.idtracking import symbols_for_node
+
+
+def test_basics():
+ for_loop = nodes.For(
nodes.Name("foo", "store"),
nodes.Name("seq", "load"),
[nodes.Output([nodes.Name("foo", "load")])],
@@ -14,33 +14,33 @@ def test_basics():
tmpl = nodes.Template(
[nodes.Assign(nodes.Name("foo", "store"), nodes.Name("bar", "load")), for_loop]
)
-
- sym = symbols_for_node(tmpl)
- assert sym.refs == {
+
+ sym = symbols_for_node(tmpl)
+ assert sym.refs == {
"foo": "l_0_foo",
"bar": "l_0_bar",
"seq": "l_0_seq",
- }
- assert sym.loads == {
+ }
+ assert sym.loads == {
"l_0_foo": ("undefined", None),
"l_0_bar": ("resolve", "bar"),
"l_0_seq": ("resolve", "seq"),
- }
-
- sym = symbols_for_node(for_loop, sym)
- assert sym.refs == {
+ }
+
+ sym = symbols_for_node(for_loop, sym)
+ assert sym.refs == {
"foo": "l_1_foo",
- }
- assert sym.loads == {
+ }
+ assert sym.loads == {
"l_1_foo": ("param", None),
- }
-
-
-def test_complex():
+ }
+
+
+def test_complex():
title_block = nodes.Block(
"title", [nodes.Output([nodes.TemplateData(u"Page Title")])], False
)
-
+
render_title_macro = nodes.Macro(
"render_title",
[nodes.Name("title", "param")],
@@ -97,8 +97,8 @@ def test_complex():
),
],
)
-
- for_loop = nodes.For(
+
+ for_loop = nodes.For(
nodes.Name("item", "store"),
nodes.Name("seq", "load"),
[
@@ -116,7 +116,7 @@ def test_complex():
None,
False,
)
-
+
body_block = nodes.Block(
"body",
[
@@ -138,7 +138,7 @@ def test_complex():
],
False,
)
-
+
tmpl = nodes.Template(
[
nodes.Extends(nodes.Const("layout.html")),
@@ -147,68 +147,68 @@ def test_complex():
body_block,
]
)
-
- tmpl_sym = symbols_for_node(tmpl)
- assert tmpl_sym.refs == {
+
+ tmpl_sym = symbols_for_node(tmpl)
+ assert tmpl_sym.refs == {
"render_title": "l_0_render_title",
- }
- assert tmpl_sym.loads == {
+ }
+ assert tmpl_sym.loads == {
"l_0_render_title": ("undefined", None),
- }
+ }
assert tmpl_sym.stores == set(["render_title"])
- assert tmpl_sym.dump_stores() == {
+ assert tmpl_sym.dump_stores() == {
"render_title": "l_0_render_title",
- }
-
- macro_sym = symbols_for_node(render_title_macro, tmpl_sym)
- assert macro_sym.refs == {
+ }
+
+ macro_sym = symbols_for_node(render_title_macro, tmpl_sym)
+ assert macro_sym.refs == {
"subtitle": "l_1_subtitle",
"something": "l_1_something",
"title": "l_1_title",
"title_upper": "l_1_title_upper",
- }
- assert macro_sym.loads == {
+ }
+ assert macro_sym.loads == {
"l_1_subtitle": ("resolve", "subtitle"),
"l_1_something": ("resolve", "something"),
"l_1_title": ("param", None),
"l_1_title_upper": ("resolve", "title_upper"),
- }
+ }
assert macro_sym.stores == set(["title", "title_upper", "subtitle"])
assert macro_sym.find_ref("render_title") == "l_0_render_title"
- assert macro_sym.dump_stores() == {
+ assert macro_sym.dump_stores() == {
"title": "l_1_title",
"title_upper": "l_1_title_upper",
"subtitle": "l_1_subtitle",
"render_title": "l_0_render_title",
- }
-
- body_sym = symbols_for_node(body_block)
- assert body_sym.refs == {
+ }
+
+ body_sym = symbols_for_node(body_block)
+ assert body_sym.refs == {
"item": "l_0_item",
"seq": "l_0_seq",
"render_title": "l_0_render_title",
- }
- assert body_sym.loads == {
+ }
+ assert body_sym.loads == {
"l_0_item": ("resolve", "item"),
"l_0_seq": ("resolve", "seq"),
"l_0_render_title": ("resolve", "render_title"),
- }
- assert body_sym.stores == set([])
-
- for_sym = symbols_for_node(for_loop, body_sym)
- assert for_sym.refs == {
+ }
+ assert body_sym.stores == set([])
+
+ for_sym = symbols_for_node(for_loop, body_sym)
+ assert for_sym.refs == {
"item": "l_1_item",
- }
- assert for_sym.loads == {
+ }
+ assert for_sym.loads == {
"l_1_item": ("param", None),
- }
+ }
assert for_sym.stores == set(["item"])
- assert for_sym.dump_stores() == {
+ assert for_sym.dump_stores() == {
"item": "l_1_item",
- }
-
-
-def test_if_branching_stores():
+ }
+
+
+def test_if_branching_stores():
tmpl = nodes.Template(
[
nodes.If(
@@ -219,20 +219,20 @@ def test_if_branching_stores():
)
]
)
-
- sym = symbols_for_node(tmpl)
+
+ sym = symbols_for_node(tmpl)
assert sym.refs == {"variable": "l_0_variable", "expression": "l_0_expression"}
assert sym.stores == set(["variable"])
- assert sym.loads == {
+ assert sym.loads == {
"l_0_variable": ("resolve", "variable"),
"l_0_expression": ("resolve", "expression"),
- }
- assert sym.dump_stores() == {
+ }
+ assert sym.dump_stores() == {
"variable": "l_0_variable",
- }
-
-
-def test_if_branching_stores_undefined():
+ }
+
+
+def test_if_branching_stores_undefined():
tmpl = nodes.Template(
[
nodes.Assign(nodes.Name("variable", "store"), nodes.Const(23)),
@@ -244,20 +244,20 @@ def test_if_branching_stores_undefined():
),
]
)
-
- sym = symbols_for_node(tmpl)
+
+ sym = symbols_for_node(tmpl)
assert sym.refs == {"variable": "l_0_variable", "expression": "l_0_expression"}
assert sym.stores == set(["variable"])
- assert sym.loads == {
+ assert sym.loads == {
"l_0_variable": ("undefined", None),
"l_0_expression": ("resolve", "expression"),
- }
- assert sym.dump_stores() == {
+ }
+ assert sym.dump_stores() == {
"variable": "l_0_variable",
- }
-
-
-def test_if_branching_multi_scope():
+ }
+
+
+def test_if_branching_multi_scope():
for_loop = nodes.For(
nodes.Name("item", "store"),
nodes.Name("seq", "load"),
@@ -274,16 +274,16 @@ def test_if_branching_multi_scope():
None,
False,
)
-
+
tmpl = nodes.Template(
[nodes.Assign(nodes.Name("x", "store"), nodes.Const(23)), for_loop]
)
-
- tmpl_sym = symbols_for_node(tmpl)
- for_sym = symbols_for_node(for_loop, tmpl_sym)
+
+ tmpl_sym = symbols_for_node(tmpl)
+ for_sym = symbols_for_node(for_loop, tmpl_sym)
assert for_sym.stores == set(["item", "x"])
- assert for_sym.loads == {
+ assert for_sym.loads == {
"l_1_x": ("alias", "l_0_x"),
"l_1_item": ("param", None),
"l_1_expression": ("resolve", "expression"),
- }
+ }