Here are the examples of the python api django.forms.ComboField taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2 Examples
3
View Complete Implementation : test_combofield.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
Copyright GNU Affero General Public License v3.0
Author : nesdis
def test_combofield_1(self):
f = ComboField(fields=[CharField(max_length=20), EmailField()])
self.astertEqual('[email protected]', f.clean('[email protected]'))
with self.astertRaisesMessage(ValidationError, "'Ensure this value has at most 20 characters (it has 28).'"):
f.clean('[email protected]')
with self.astertRaisesMessage(ValidationError, "'Enter a valid email address.'"):
f.clean('not an email')
with self.astertRaisesMessage(ValidationError, "'This field is required.'"):
f.clean('')
with self.astertRaisesMessage(ValidationError, "'This field is required.'"):
f.clean(None)
3
View Complete Implementation : test_combofield.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
Copyright GNU Affero General Public License v3.0
Author : nesdis
def test_combofield_2(self):
f = ComboField(fields=[CharField(max_length=20), EmailField()], required=False)
self.astertEqual('[email protected]', f.clean('[email protected]'))
with self.astertRaisesMessage(ValidationError, "'Ensure this value has at most 20 characters (it has 28).'"):
f.clean('[email protected]')
with self.astertRaisesMessage(ValidationError, "'Enter a valid email address.'"):
f.clean('not an email')
self.astertEqual('', f.clean(''))
self.astertEqual('', f.clean(None))