summaryrefslogtreecommitdiff
path: root/tests/forms_tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/forms_tests')
-rw-r--r--tests/forms_tests/tests/test_forms.py15
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