aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/Jinja2/py3/tests
diff options
context:
space:
mode:
authorrobot-contrib <robot-contrib@yandex-team.com>2024-05-20 09:01:58 +0300
committerrobot-contrib <robot-contrib@yandex-team.com>2024-05-20 09:13:14 +0300
commit113478c6a7e201ab2d7ad78d9edbc28800283a75 (patch)
tree98b88d8dc4bfe5c664f813ead96eefb0f456e2a9 /contrib/python/Jinja2/py3/tests
parent685fde8e2a4228200a88a5987a061329f7c59323 (diff)
downloadydb-113478c6a7e201ab2d7ad78d9edbc28800283a75.tar.gz
Update contrib/python/Jinja2/py3 to 3.1.4
264ae85f13f4a11226be8b846079da1aece08b50
Diffstat (limited to 'contrib/python/Jinja2/py3/tests')
-rw-r--r--contrib/python/Jinja2/py3/tests/test_api.py5
-rw-r--r--contrib/python/Jinja2/py3/tests/test_filters.py11
-rw-r--r--contrib/python/Jinja2/py3/tests/test_inheritance.py22
-rw-r--r--contrib/python/Jinja2/py3/tests/test_regression.py1
4 files changed, 18 insertions, 21 deletions
diff --git a/contrib/python/Jinja2/py3/tests/test_api.py b/contrib/python/Jinja2/py3/tests/test_api.py
index 4db3b4a96a..ff3fcb138b 100644
--- a/contrib/python/Jinja2/py3/tests/test_api.py
+++ b/contrib/python/Jinja2/py3/tests/test_api.py
@@ -150,7 +150,8 @@ class TestExtendedAPI:
assert t.render(foo="<foo>") == "<foo>"
def test_sandbox_max_range(self, env):
- from jinja2.sandbox import SandboxedEnvironment, MAX_RANGE
+ from jinja2.sandbox import MAX_RANGE
+ from jinja2.sandbox import SandboxedEnvironment
env = SandboxedEnvironment()
t = env.from_string("{% for item in range(total) %}{{ item }}{% endfor %}")
@@ -264,7 +265,7 @@ class TestUndefined:
def test_undefined_and_special_attributes(self):
with pytest.raises(AttributeError):
- Undefined("Foo").__dict__
+ Undefined("Foo").__dict__ # noqa B018
def test_undefined_attribute_error(self):
# Django's LazyObject turns the __class__ attribute into a
diff --git a/contrib/python/Jinja2/py3/tests/test_filters.py b/contrib/python/Jinja2/py3/tests/test_filters.py
index f50ed13ab5..d8e9114d0f 100644
--- a/contrib/python/Jinja2/py3/tests/test_filters.py
+++ b/contrib/python/Jinja2/py3/tests/test_filters.py
@@ -474,11 +474,12 @@ class TestFilter:
assert 'bar="23"' in out
assert 'blub:blub="&lt;?&gt;"' in out
- def test_xmlattr_key_with_spaces(self, env):
- with pytest.raises(ValueError, match="Spaces are not allowed"):
- env.from_string(
- "{{ {'src=1 onerror=alert(1)': 'my_class'}|xmlattr }}"
- ).render()
+ @pytest.mark.parametrize("sep", ("\t", "\n", "\f", " ", "/", ">", "="))
+ def test_xmlattr_key_invalid(self, env: Environment, sep: str) -> None:
+ with pytest.raises(ValueError, match="Invalid character"):
+ env.from_string("{{ {key: 'my_class'}|xmlattr }}").render(
+ key=f"class{sep}onclick=alert(1)"
+ )
def test_sort1(self, env):
tmpl = env.from_string("{{ [2, 3, 1]|sort }}|{{ [2, 3, 1]|sort(true) }}")
diff --git a/contrib/python/Jinja2/py3/tests/test_inheritance.py b/contrib/python/Jinja2/py3/tests/test_inheritance.py
index 0a525e7ac9..0f5fed5536 100644
--- a/contrib/python/Jinja2/py3/tests/test_inheritance.py
+++ b/contrib/python/Jinja2/py3/tests/test_inheritance.py
@@ -365,11 +365,10 @@ class TestInheritance:
class TestBugFix:
def test_fixed_macro_scoping_bug(self, env):
- assert (
- Environment(
- loader=DictLoader(
- {
- "test.html": """\
+ assert Environment(
+ loader=DictLoader(
+ {
+ "test.html": """\
{% extends 'details.html' %}
{% macro my_macro() %}
@@ -380,7 +379,7 @@ class TestBugFix:
{{ my_macro() }}
{% endblock %}
""",
- "details.html": """\
+ "details.html": """\
{% extends 'standard.html' %}
{% macro my_macro() %}
@@ -396,17 +395,12 @@ class TestBugFix:
{% endblock %}
{% endblock %}
""",
- "standard.html": """
+ "standard.html": """
{% block content %}&nbsp;{% endblock %}
""",
- }
- )
+ }
)
- .get_template("test.html")
- .render()
- .split()
- == ["outer_box", "my_macro"]
- )
+ ).get_template("test.html").render().split() == ["outer_box", "my_macro"]
def test_double_extends(self, env):
"""Ensures that a template with more than 1 {% extends ... %} usage
diff --git a/contrib/python/Jinja2/py3/tests/test_regression.py b/contrib/python/Jinja2/py3/tests/test_regression.py
index 46e492bdd5..7bd4d15649 100644
--- a/contrib/python/Jinja2/py3/tests/test_regression.py
+++ b/contrib/python/Jinja2/py3/tests/test_regression.py
@@ -599,6 +599,7 @@ class TestBug:
def test_markup_and_chainable_undefined(self):
from markupsafe import Markup
+
from jinja2.runtime import ChainableUndefined
assert str(Markup(ChainableUndefined())) == ""