summaryrefslogtreecommitdiff
path: root/tests/forms_tests
diff options
context:
space:
mode:
authorMoritz Sichert <moritz.sichert@googlemail.com>2015-08-10 10:55:49 +0200
committerTim Graham <timograham@gmail.com>2015-09-16 10:18:07 -0400
commit535809e12161d28dacaf5161436fc05a9bb064aa (patch)
tree6b5dbd0e7c33221487f3857b2fef068d6c885315 /tests/forms_tests
parent8615e415861ea93afb5a84365895bd7b9af7be6f (diff)
downloaddjango-535809e12161d28dacaf5161436fc05a9bb064aa.tar.gz
Fixed #25294 -- Allowed custom BoundFields on forms.
Diffstat (limited to 'tests/forms_tests')
-rw-r--r--tests/forms_tests/tests/test_forms.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py
index ac96d775a2..d3618b1a8c 100644
--- a/tests/forms_tests/tests/test_forms.py
+++ b/tests/forms_tests/tests/test_forms.py
@@ -1903,6 +1903,17 @@ Password: <input type="password" name="password" /></li>
f = SampleForm(data={'name': 'bar'})
self.assertIsInstance(force_text(f['name']), SafeData)
+ def test_custom_boundfield(self):
+ class CustomField(CharField):
+ def get_bound_field(self, form, name):
+ return (form, name)
+
+ class SampleForm(Form):
+ name = CustomField()
+
+ f = SampleForm()
+ self.assertEqual(f['name'], (f, 'name'))
+
def test_initial_datetime_values(self):
now = datetime.datetime.now()
# Nix microseconds (since they should be ignored). #22502