aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/Jinja2/py3/tests/test_tests.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/py3/tests/test_tests.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/py3/tests/test_tests.py')
-rw-r--r--contrib/python/Jinja2/py3/tests/test_tests.py92
1 files changed, 46 insertions, 46 deletions
diff --git a/contrib/python/Jinja2/py3/tests/test_tests.py b/contrib/python/Jinja2/py3/tests/test_tests.py
index 75178d6adfb..1fc5fe9fedc 100644
--- a/contrib/python/Jinja2/py3/tests/test_tests.py
+++ b/contrib/python/Jinja2/py3/tests/test_tests.py
@@ -1,32 +1,32 @@
import pytest
from markupsafe import Markup
-
+
from jinja2 import Environment
from jinja2 import TemplateAssertionError
from jinja2 import TemplateRuntimeError
-
-
+
+
class MyDict(dict):
pass
-
-
+
+
class TestTestsCase:
- def test_defined(self, env):
+ def test_defined(self, env):
tmpl = env.from_string("{{ missing is defined }}|{{ true is defined }}")
assert tmpl.render() == "False|True"
-
- def test_even(self, env):
+
+ def test_even(self, env):
tmpl = env.from_string("""{{ 1 is even }}|{{ 2 is even }}""")
assert tmpl.render() == "False|True"
-
- def test_odd(self, env):
+
+ def test_odd(self, env):
tmpl = env.from_string("""{{ 1 is odd }}|{{ 2 is odd }}""")
assert tmpl.render() == "True|False"
-
- def test_lower(self, env):
+
+ def test_lower(self, env):
tmpl = env.from_string("""{{ "foo" is lower }}|{{ "FOO" is lower }}""")
assert tmpl.render() == "True|False"
-
+
# Test type checks
@pytest.mark.parametrize(
"op,expect",
@@ -113,27 +113,27 @@ class TestTestsCase:
def test_types(self, env, op, expect):
t = env.from_string(f"{{{{ {op} }}}}")
assert t.render(mydict=MyDict(), complex=complex(1, 2)) == str(expect)
-
- def test_upper(self, env):
- tmpl = env.from_string('{{ "FOO" is upper }}|{{ "foo" is upper }}')
+
+ def test_upper(self, env):
+ tmpl = env.from_string('{{ "FOO" is upper }}|{{ "foo" is upper }}')
assert tmpl.render() == "True|False"
-
- def test_equalto(self, env):
- tmpl = env.from_string(
+
+ def test_equalto(self, env):
+ tmpl = env.from_string(
"{{ foo is eq 12 }}|"
"{{ foo is eq 0 }}|"
"{{ foo is eq (3 * 4) }}|"
- '{{ bar is eq "baz" }}|'
- '{{ bar is eq "zab" }}|'
- '{{ bar is eq ("ba" + "z") }}|'
+ '{{ bar is eq "baz" }}|'
+ '{{ bar is eq "zab" }}|'
+ '{{ bar is eq ("ba" + "z") }}|'
"{{ bar is eq bar }}|"
"{{ bar is eq foo }}"
- )
+ )
assert (
tmpl.render(foo=12, bar="baz")
== "True|False|True|True|False|True|True|False"
)
-
+
@pytest.mark.parametrize(
"op,expect",
(
@@ -151,39 +151,39 @@ class TestTestsCase:
("ge 3", False),
),
)
- def test_compare_aliases(self, env, op, expect):
+ def test_compare_aliases(self, env, op, expect):
t = env.from_string(f"{{{{ 2 is {op} }}}}")
- assert t.render() == str(expect)
-
- def test_sameas(self, env):
+ assert t.render() == str(expect)
+
+ def test_sameas(self, env):
tmpl = env.from_string("{{ foo is sameas false }}|{{ 0 is sameas false }}")
assert tmpl.render(foo=False) == "True|False"
-
- def test_no_paren_for_arg1(self, env):
+
+ def test_no_paren_for_arg1(self, env):
tmpl = env.from_string("{{ foo is sameas none }}")
assert tmpl.render(foo=None) == "True"
-
- def test_escaped(self, env):
- env = Environment(autoescape=True)
+
+ def test_escaped(self, env):
+ env = Environment(autoescape=True)
tmpl = env.from_string("{{ x is escaped }}|{{ y is escaped }}")
assert tmpl.render(x="foo", y=Markup("foo")) == "False|True"
-
- def test_greaterthan(self, env):
+
+ def test_greaterthan(self, env):
tmpl = env.from_string("{{ 1 is greaterthan 0 }}|{{ 0 is greaterthan 1 }}")
assert tmpl.render() == "True|False"
-
- def test_lessthan(self, env):
+
+ def test_lessthan(self, env):
tmpl = env.from_string("{{ 0 is lessthan 1 }}|{{ 1 is lessthan 0 }}")
assert tmpl.render() == "True|False"
+
+ def test_multiple_tests(self):
+ items = []
- def test_multiple_tests(self):
- items = []
+ def matching(x, y):
+ items.append((x, y))
+ return False
- def matching(x, y):
- items.append((x, y))
- return False
-
- env = Environment()
+ env = Environment()
env.tests["matching"] = matching
tmpl = env.from_string(
"{{ 'us-west-1' is matching '(us-east-1|ap-northeast-1)'"
@@ -194,8 +194,8 @@ class TestTestsCase:
("us-west-1", "(us-east-1|ap-northeast-1)"),
("stage", "(dev|stage)"),
]
-
- def test_in(self, env):
+
+ def test_in(self, env):
tmpl = env.from_string(
'{{ "o" is in "foo" }}|'
'{{ "foo" is in "foo" }}|'