mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
Fixed #28001 -- Updated comment and tested context popping in ForNode.render().
This commit is contained in:
parent
351835f262
commit
dbfcedb499
2 changed files with 20 additions and 5 deletions
|
@ -180,3 +180,20 @@ class ForTagTests(SimpleTestCase):
|
|||
def test_for_tag_unpack14(self):
|
||||
with self.assertRaisesMessage(ValueError, 'Need 2 values to unpack in for loop; got 1.'):
|
||||
self.engine.render_to_string('for-tag-unpack14', {'items': (1, 2)})
|
||||
|
||||
@setup({
|
||||
'main': '{% with alpha=alpha.values %}{% include "base" %}{% endwith %}_'
|
||||
'{% with alpha=alpha.extra %}{% include "base" %}{% endwith %}',
|
||||
'base': '{% for x, y in alpha %}{{ x }}:{{ y }},{% endfor %}'
|
||||
})
|
||||
def test_for_tag_context(self):
|
||||
"""
|
||||
ForNode.render() pops the values it pushes to the context (#28001).
|
||||
"""
|
||||
output = self.engine.render_to_string('main', {
|
||||
'alpha': {
|
||||
'values': [('two', 2), ('four', 4)],
|
||||
'extra': [('six', 6), ('eight', 8)],
|
||||
},
|
||||
})
|
||||
self.assertEqual(output, 'two:2,four:4,_six:6,eight:8,')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue