diff options
| author | django-bot <ops@djangoproject.com> | 2022-02-08 12:09:55 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-02-08 12:15:38 +0100 |
| commit | 6a682b38e75d4c975b4c4493565a59f1bc14397c (patch) | |
| tree | 0bd9cda550bea26238656d9f120d769e8b41bb9e /tests/template_tests/syntax_tests/test_list_index.py | |
| parent | e73ce08888e6f34d3f050377cfd2fbb733be94a9 (diff) | |
[4.0.x] Refs #33476 -- Reformatted code with Black.
Backport of 9c19aff7c7561e3a82978a272ecdaad40dda5c00 from main.
Diffstat (limited to 'tests/template_tests/syntax_tests/test_list_index.py')
| -rw-r--r-- | tests/template_tests/syntax_tests/test_list_index.py | 55 |
1 files changed, 30 insertions, 25 deletions
diff --git a/tests/template_tests/syntax_tests/test_list_index.py b/tests/template_tests/syntax_tests/test_list_index.py index d1be0cb1a4..261e7dfdba 100644 --- a/tests/template_tests/syntax_tests/test_list_index.py +++ b/tests/template_tests/syntax_tests/test_list_index.py @@ -4,72 +4,77 @@ from ..utils import setup class ListIndexTests(SimpleTestCase): - - @setup({'list-index01': '{{ var.1 }}'}) + @setup({"list-index01": "{{ var.1 }}"}) def test_list_index01(self): """ List-index syntax allows a template to access a certain item of a subscriptable object. """ - output = self.engine.render_to_string('list-index01', {'var': ['first item', 'second item']}) - self.assertEqual(output, 'second item') + output = self.engine.render_to_string( + "list-index01", {"var": ["first item", "second item"]} + ) + self.assertEqual(output, "second item") - @setup({'list-index02': '{{ var.5 }}'}) + @setup({"list-index02": "{{ var.5 }}"}) def test_list_index02(self): """ Fail silently when the list index is out of range. """ - output = self.engine.render_to_string('list-index02', {'var': ['first item', 'second item']}) + output = self.engine.render_to_string( + "list-index02", {"var": ["first item", "second item"]} + ) if self.engine.string_if_invalid: - self.assertEqual(output, 'INVALID') + self.assertEqual(output, "INVALID") else: - self.assertEqual(output, '') + self.assertEqual(output, "") - @setup({'list-index03': '{{ var.1 }}'}) + @setup({"list-index03": "{{ var.1 }}"}) def test_list_index03(self): """ Fail silently when the list index is out of range. """ - output = self.engine.render_to_string('list-index03', {'var': None}) + output = self.engine.render_to_string("list-index03", {"var": None}) if self.engine.string_if_invalid: - self.assertEqual(output, 'INVALID') + self.assertEqual(output, "INVALID") else: - self.assertEqual(output, '') + self.assertEqual(output, "") - @setup({'list-index04': '{{ var.1 }}'}) + @setup({"list-index04": "{{ var.1 }}"}) def test_list_index04(self): """ Fail silently when variable is a dict without the specified key. """ - output = self.engine.render_to_string('list-index04', {'var': {}}) + output = self.engine.render_to_string("list-index04", {"var": {}}) if self.engine.string_if_invalid: - self.assertEqual(output, 'INVALID') + self.assertEqual(output, "INVALID") else: - self.assertEqual(output, '') + self.assertEqual(output, "") - @setup({'list-index05': '{{ var.1 }}'}) + @setup({"list-index05": "{{ var.1 }}"}) def test_list_index05(self): """ Dictionary lookup wins out when dict's key is a string. """ - output = self.engine.render_to_string('list-index05', {'var': {'1': "hello"}}) - self.assertEqual(output, 'hello') + output = self.engine.render_to_string("list-index05", {"var": {"1": "hello"}}) + self.assertEqual(output, "hello") - @setup({'list-index06': '{{ var.1 }}'}) + @setup({"list-index06": "{{ var.1 }}"}) def test_list_index06(self): """ But list-index lookup wins out when dict's key is an int, which behind the scenes is really a dictionary lookup (for a dict) after converting the key to an int. """ - output = self.engine.render_to_string('list-index06', {"var": {1: "hello"}}) - self.assertEqual(output, 'hello') + output = self.engine.render_to_string("list-index06", {"var": {1: "hello"}}) + self.assertEqual(output, "hello") - @setup({'list-index07': '{{ var.1 }}'}) + @setup({"list-index07": "{{ var.1 }}"}) def test_list_index07(self): """ Dictionary lookup wins out when there is a string and int version of the key. """ - output = self.engine.render_to_string('list-index07', {"var": {'1': "hello", 1: "world"}}) - self.assertEqual(output, 'hello') + output = self.engine.render_to_string( + "list-index07", {"var": {"1": "hello", 1: "world"}} + ) + self.assertEqual(output, "hello") |
