diff options
| author | Chris Beaven <smileychris@gmail.com> | 2010-11-28 02:50:31 +0000 |
|---|---|---|
| committer | Chris Beaven <smileychris@gmail.com> | 2010-11-28 02:50:31 +0000 |
| commit | d3f5f219f5f42ac3504ed626dcb92f4ee2dc3d5f (patch) | |
| tree | 610a47472e403afeeaceaa635b2108d883ee2cc2 /tests | |
| parent | e74edb4d53b089ec57ec4830eeba98607283a092 (diff) | |
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
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/forms/tests/forms.py | 15 |
1 files changed, 15 insertions, 0 deletions
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): <option value="w">whiz</option> </select></li>""") + 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): |
