mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Moved declaration of test form inside the relevant test for clarity.
This commit is contained in:
parent
a885bca1df
commit
6f5fcfc6d2
@ -8,38 +8,36 @@ from django.core import validators
|
||||
from django.core.exceptions import ValidationError
|
||||
|
||||
|
||||
class UserForm(forms.Form):
|
||||
full_name = forms.CharField(
|
||||
max_length=50,
|
||||
validators=[
|
||||
validators.validate_integer,
|
||||
validators.validate_email,
|
||||
]
|
||||
)
|
||||
string = forms.CharField(
|
||||
max_length=50,
|
||||
validators=[
|
||||
validators.RegexValidator(
|
||||
regex='^[a-zA-Z]*$',
|
||||
message="Letters only.",
|
||||
)
|
||||
]
|
||||
)
|
||||
ignore_case_string = forms.CharField(
|
||||
max_length=50,
|
||||
validators=[
|
||||
validators.RegexValidator(
|
||||
regex='^[a-z]*$',
|
||||
message="Letters only.",
|
||||
flags=re.IGNORECASE,
|
||||
)
|
||||
]
|
||||
|
||||
)
|
||||
|
||||
|
||||
class TestFieldWithValidators(TestCase):
|
||||
def test_all_errors_get_reported(self):
|
||||
class UserForm(forms.Form):
|
||||
full_name = forms.CharField(
|
||||
max_length=50,
|
||||
validators=[
|
||||
validators.validate_integer,
|
||||
validators.validate_email,
|
||||
]
|
||||
)
|
||||
string = forms.CharField(
|
||||
max_length=50,
|
||||
validators=[
|
||||
validators.RegexValidator(
|
||||
regex='^[a-zA-Z]*$',
|
||||
message="Letters only.",
|
||||
)
|
||||
]
|
||||
)
|
||||
ignore_case_string = forms.CharField(
|
||||
max_length=50,
|
||||
validators=[
|
||||
validators.RegexValidator(
|
||||
regex='^[a-z]*$',
|
||||
message="Letters only.",
|
||||
flags=re.IGNORECASE,
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
form = UserForm({
|
||||
'full_name': 'not int nor mail',
|
||||
'string': '2 is not correct',
|
||||
|
Loading…
Reference in New Issue
Block a user