summaryrefslogtreecommitdiff
path: root/tests/forms_tests
diff options
context:
space:
mode:
authorHerbert Parentes Fortes Neto <hpfn@debian.org>2018-02-12 10:45:37 -0200
committerTim Graham <timograham@gmail.com>2018-02-15 13:44:26 -0500
commitd368784bacc7e58b426f29937ee842aa14d439ad (patch)
tree4a1613ea50e2cd59af777ac8e296a6ce50a78d49 /tests/forms_tests
parente917ea6bec45d7f789ca96a13be15df9521963e1 (diff)
Fixed #28171 -- Added an exception if Form's empty_permitted and use_required_attribute arguments conflict.
Diffstat (limited to 'tests/forms_tests')
-rw-r--r--tests/forms_tests/tests/test_forms.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py
index 1f883e1a28..b326468d69 100644
--- a/tests/forms_tests/tests/test_forms.py
+++ b/tests/forms_tests/tests/test_forms.py
@@ -2682,7 +2682,7 @@ Good luck picking a username that doesn&#39;t already exist.</p>
self.assertEqual(form.cleaned_data, {})
# Now let's show what happens when empty_permitted=True and the form is empty.
- form = SongForm(data, empty_permitted=True)
+ form = SongForm(data, empty_permitted=True, use_required_attribute=False)
self.assertTrue(form.is_valid())
self.assertEqual(form.errors, {})
self.assertEqual(form.cleaned_data, {})
@@ -2699,7 +2699,7 @@ Good luck picking a username that doesn&#39;t already exist.</p>
# make sure that when checking for empty_permitted that None is treated
# accordingly.
data = {'artist': None, 'song': ''}
- form = SongForm(data, empty_permitted=True)
+ form = SongForm(data, empty_permitted=True, use_required_attribute=False)
self.assertTrue(form.is_valid())
# However, we *really* need to be sure we are checking for None as any data in
@@ -2709,9 +2709,17 @@ Good luck picking a username that doesn&#39;t already exist.</p>
qty = IntegerField()
data = {'amount': '0.0', 'qty': ''}
- form = PriceForm(data, initial={'amount': 0.0}, empty_permitted=True)
+ form = PriceForm(data, initial={'amount': 0.0}, empty_permitted=True, use_required_attribute=False)
self.assertTrue(form.is_valid())
+ def test_empty_permitted_and_use_required_attribute(self):
+ msg = (
+ 'The empty_permitted and use_required_attribute arguments may not '
+ 'both be True.'
+ )
+ with self.assertRaisesMessage(ValueError, msg):
+ Person(empty_permitted=True, use_required_attribute=True)
+
def test_extracting_hidden_and_visible(self):
class SongForm(Form):
token = CharField(widget=HiddenInput)