From d3f5f219f5f42ac3504ed626dcb92f4ee2dc3d5f Mon Sep 17 00:00:00 2001 From: Chris Beaven Date: Sun, 28 Nov 2010 02:50:31 +0000 Subject: Fixes #10427 -- Abstract the value generation of a BoundField git-svn-id: http://code.djangoproject.com/svn/django/trunk@14734 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/regressiontests/forms/tests/forms.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/regressiontests/forms') diff --git a/tests/regressiontests/forms/tests/forms.py b/tests/regressiontests/forms/tests/forms.py index b52a0537ee..91a7472cd1 100644 --- a/tests/regressiontests/forms/tests/forms.py +++ b/tests/regressiontests/forms/tests/forms.py @@ -1151,6 +1151,21 @@ class FormsTestCase(TestCase): """) + def test_boundfield_values(self): + # It's possible to get to the value which would be used for rendering + # the widget for a field by using the BoundField's value method. + + class UserRegistration(Form): + username = CharField(max_length=10, initial='djangonaut') + password = CharField(widget=PasswordInput) + + unbound = UserRegistration() + bound = UserRegistration({'password': 'foo'}) + self.assertEqual(bound['username'].value(), None) + self.assertEqual(unbound['username'].value(), 'djangonaut') + self.assertEqual(bound['password'].value(), 'foo') + self.assertEqual(unbound['password'].value(), None) + def test_help_text(self): # You can specify descriptive text for a field by using the 'help_text' argument) class UserRegistration(Form): -- cgit v1.3