diff options
| author | Michael Angeletti <michael@angelettigroup.com> | 2015-02-22 22:06:41 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-02-24 19:50:55 -0500 |
| commit | 65441bbdb02427655869c42791a0bc5a9c631292 (patch) | |
| tree | a13315b58f68dbd8374d3d91e9b6942442db2c69 /tests/forms_tests | |
| parent | d298b1ba5043eaa40f3f4bebe3c7634b359ba34b (diff) | |
Fixed #24391 -- Made BoundField.value() cache callable values.
Diffstat (limited to 'tests/forms_tests')
| -rw-r--r-- | tests/forms_tests/tests/test_forms.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py index 4024f0359e..589a9cfc84 100644 --- a/tests/forms_tests/tests/test_forms.py +++ b/tests/forms_tests/tests/test_forms.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import copy import datetime import json +import uuid from django.core.exceptions import NON_FIELD_ERRORS from django.core.files.uploadedfile import SimpleUploadedFile @@ -1369,6 +1370,20 @@ class FormsTestCase(TestCase): self.assertEqual(bound['password'].value(), 'foo') self.assertEqual(unbound['password'].value(), None) + def test_boundfield_initial_called_once(self): + """ + Multiple calls to BoundField().value() in an unbound form should return + the same result each time (#24391). + """ + class MyForm(Form): + name = CharField(max_length=10, initial=uuid.uuid4) + + form = MyForm() + name = form['name'] + self.assertEqual(name.value(), name.value()) + # BoundField is also cached + self.assertIs(form['name'], name) + def test_boundfield_rendering(self): """ Python 2 issue: Test that rendering a BoundField with bytestring content |
