summaryrefslogtreecommitdiff
path: root/tests/template_tests/syntax_tests/test_with.py
diff options
context:
space:
mode:
authordjango-bot <ops@djangoproject.com>2022-02-03 20:24:19 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-02-07 20:37:05 +0100
commit9c19aff7c7561e3a82978a272ecdaad40dda5c00 (patch)
treef0506b668a013d0063e5fba3dbf4863b466713ba /tests/template_tests/syntax_tests/test_with.py
parentf68fa8b45dfac545cfc4111d4e52804c86db68d3 (diff)
Refs #33476 -- Reformatted code with Black.
Diffstat (limited to 'tests/template_tests/syntax_tests/test_with.py')
-rw-r--r--tests/template_tests/syntax_tests/test_with.py62
1 files changed, 35 insertions, 27 deletions
diff --git a/tests/template_tests/syntax_tests/test_with.py b/tests/template_tests/syntax_tests/test_with.py
index d8f24349f5..dde581eab3 100644
--- a/tests/template_tests/syntax_tests/test_with.py
+++ b/tests/template_tests/syntax_tests/test_with.py
@@ -8,53 +8,61 @@ from ..utils import setup
class WithTagTests(SimpleTestCase):
at_least_with_one_msg = "'with' expected at least one variable assignment"
- @setup({'with01': '{% with key=dict.key %}{{ key }}{% endwith %}'})
+ @setup({"with01": "{% with key=dict.key %}{{ key }}{% endwith %}"})
def test_with01(self):
- output = self.engine.render_to_string('with01', {'dict': {'key': 50}})
- self.assertEqual(output, '50')
+ output = self.engine.render_to_string("with01", {"dict": {"key": 50}})
+ self.assertEqual(output, "50")
- @setup({'legacywith01': '{% with dict.key as key %}{{ key }}{% endwith %}'})
+ @setup({"legacywith01": "{% with dict.key as key %}{{ key }}{% endwith %}"})
def test_legacywith01(self):
- output = self.engine.render_to_string('legacywith01', {'dict': {'key': 50}})
- self.assertEqual(output, '50')
+ output = self.engine.render_to_string("legacywith01", {"dict": {"key": 50}})
+ self.assertEqual(output, "50")
- @setup({'with02': '{{ key }}{% with key=dict.key %}'
- '{{ key }}-{{ dict.key }}-{{ key }}'
- '{% endwith %}{{ key }}'})
+ @setup(
+ {
+ "with02": "{{ key }}{% with key=dict.key %}"
+ "{{ key }}-{{ dict.key }}-{{ key }}"
+ "{% endwith %}{{ key }}"
+ }
+ )
def test_with02(self):
- output = self.engine.render_to_string('with02', {'dict': {'key': 50}})
+ output = self.engine.render_to_string("with02", {"dict": {"key": 50}})
if self.engine.string_if_invalid:
- self.assertEqual(output, 'INVALID50-50-50INVALID')
+ self.assertEqual(output, "INVALID50-50-50INVALID")
else:
- self.assertEqual(output, '50-50-50')
+ self.assertEqual(output, "50-50-50")
- @setup({'legacywith02': '{{ key }}{% with dict.key as key %}'
- '{{ key }}-{{ dict.key }}-{{ key }}'
- '{% endwith %}{{ key }}'})
+ @setup(
+ {
+ "legacywith02": "{{ key }}{% with dict.key as key %}"
+ "{{ key }}-{{ dict.key }}-{{ key }}"
+ "{% endwith %}{{ key }}"
+ }
+ )
def test_legacywith02(self):
- output = self.engine.render_to_string('legacywith02', {'dict': {'key': 50}})
+ output = self.engine.render_to_string("legacywith02", {"dict": {"key": 50}})
if self.engine.string_if_invalid:
- self.assertEqual(output, 'INVALID50-50-50INVALID')
+ self.assertEqual(output, "INVALID50-50-50INVALID")
else:
- self.assertEqual(output, '50-50-50')
+ self.assertEqual(output, "50-50-50")
- @setup({'with03': '{% with a=alpha b=beta %}{{ a }}{{ b }}{% endwith %}'})
+ @setup({"with03": "{% with a=alpha b=beta %}{{ a }}{{ b }}{% endwith %}"})
def test_with03(self):
- output = self.engine.render_to_string('with03', {'alpha': 'A', 'beta': 'B'})
- self.assertEqual(output, 'AB')
+ output = self.engine.render_to_string("with03", {"alpha": "A", "beta": "B"})
+ self.assertEqual(output, "AB")
- @setup({'with-error01': '{% with dict.key xx key %}{{ key }}{% endwith %}'})
+ @setup({"with-error01": "{% with dict.key xx key %}{{ key }}{% endwith %}"})
def test_with_error01(self):
with self.assertRaisesMessage(TemplateSyntaxError, self.at_least_with_one_msg):
- self.engine.render_to_string('with-error01', {'dict': {'key': 50}})
+ self.engine.render_to_string("with-error01", {"dict": {"key": 50}})
- @setup({'with-error02': '{% with dict.key as %}{{ key }}{% endwith %}'})
+ @setup({"with-error02": "{% with dict.key as %}{{ key }}{% endwith %}"})
def test_with_error02(self):
with self.assertRaisesMessage(TemplateSyntaxError, self.at_least_with_one_msg):
- self.engine.render_to_string('with-error02', {'dict': {'key': 50}})
+ self.engine.render_to_string("with-error02", {"dict": {"key": 50}})
class WithNodeTests(SimpleTestCase):
def test_repr(self):
- node = WithNode(nodelist=[], name='a', var='dict.key')
- self.assertEqual(repr(node), '<WithNode>')
+ node = WithNode(nodelist=[], name="a", var="dict.key")
+ self.assertEqual(repr(node), "<WithNode>")