summaryrefslogtreecommitdiff
path: root/tests/regressiontests/forms
diff options
context:
space:
mode:
authorBrian Rosner <brosner@gmail.com>2008-05-05 18:08:07 +0000
committerBrian Rosner <brosner@gmail.com>2008-05-05 18:08:07 +0000
commitf793f27df0695d5ff82f947694546b6e5ae6263a (patch)
tree7720515c78d31d878ba7948e2fc751c0ccb6f4e6 /tests/regressiontests/forms
parentbe31882eee70529b8a85ecefbeb20f7ecc0f1fd1 (diff)
newforms-admin: Fixed #7160 -- MultiWidget._has_changed was short-circuiting while testing for changed data in its widgets. Added tests to ensure this won't get broken in the future.
git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@7517 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/forms')
-rw-r--r--tests/regressiontests/forms/widgets.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/tests/regressiontests/forms/widgets.py b/tests/regressiontests/forms/widgets.py
index e20ea15175..3ebf0b5a2f 100644
--- a/tests/regressiontests/forms/widgets.py
+++ b/tests/regressiontests/forms/widgets.py
@@ -963,10 +963,19 @@ u'<input id="foo_0" type="text" class="big" value="john" name="name_0" /><br /><
u'<input id="bar_0" type="text" class="big" value="john" name="name_0" /><br /><input id="bar_1" type="text" class="small" value="lennon" name="name_1" />'
>>> w = MyMultiWidget(widgets=(TextInput(), TextInput()))
->>> w._has_changed(None, ['john', 'lennon'])
+# test with no initial data
+>>> w._has_changed(None, [u'john', u'lennon'])
True
->>> w._has_changed('john__lennon', ['john', 'lennon'])
+# test when the data is the same as initial
+>>> w._has_changed(u'john__lennon', [u'john', u'lennon'])
False
+# test when the first widget's data has changed
+>>> w._has_changed(u'john__lennon', [u'alfred', u'lennon'])
+True
+# test when the last widget's data has changed. this ensures that it is not
+# short circuiting while testing the widgets.
+>>> w._has_changed(u'john__lennon', [u'john', u'denver'])
+True
# SplitDateTimeWidget #########################################################