mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Corrected forms imports in forms_tests/tests/test_forms.py.
This commit is contained in:
parent
cfacd69ab8
commit
51967b56c4
@ -14,6 +14,7 @@ from django.forms import (
|
|||||||
DateField,
|
DateField,
|
||||||
DateTimeField,
|
DateTimeField,
|
||||||
EmailField,
|
EmailField,
|
||||||
|
Field,
|
||||||
FileField,
|
FileField,
|
||||||
FileInput,
|
FileInput,
|
||||||
FloatField,
|
FloatField,
|
||||||
@ -35,10 +36,9 @@ from django.forms import (
|
|||||||
TextInput,
|
TextInput,
|
||||||
TimeField,
|
TimeField,
|
||||||
ValidationError,
|
ValidationError,
|
||||||
forms,
|
|
||||||
)
|
)
|
||||||
from django.forms.renderers import DjangoTemplates, get_default_renderer
|
from django.forms.renderers import DjangoTemplates, get_default_renderer
|
||||||
from django.forms.utils import ErrorList
|
from django.forms.utils import ErrorDict, ErrorList
|
||||||
from django.http import QueryDict
|
from django.http import QueryDict
|
||||||
from django.template import Context, Template
|
from django.template import Context, Template
|
||||||
from django.test import SimpleTestCase
|
from django.test import SimpleTestCase
|
||||||
@ -1656,7 +1656,7 @@ class FormsTestCase(SimpleTestCase):
|
|||||||
self._errors = e.update_error_dict(self._errors)
|
self._errors = e.update_error_dict(self._errors)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
raise ValidationError({"code": forms.ErrorList(["Code error 3."])})
|
raise ValidationError({"code": ErrorList(["Code error 3."])})
|
||||||
except ValidationError as e:
|
except ValidationError as e:
|
||||||
self._errors = e.update_error_dict(self._errors)
|
self._errors = e.update_error_dict(self._errors)
|
||||||
|
|
||||||
@ -1680,7 +1680,7 @@ class FormsTestCase(SimpleTestCase):
|
|||||||
self.assertFalse(form.is_valid())
|
self.assertFalse(form.is_valid())
|
||||||
|
|
||||||
# update_error_dict didn't lose track of the ErrorDict type.
|
# update_error_dict didn't lose track of the ErrorDict type.
|
||||||
self.assertIsInstance(form._errors, forms.ErrorDict)
|
self.assertIsInstance(form._errors, ErrorDict)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
dict(form.errors),
|
dict(form.errors),
|
||||||
@ -2738,7 +2738,7 @@ Options: <select multiple name="options" aria-invalid="true" required>
|
|||||||
self.assertNotIn("birthday", p.changed_data)
|
self.assertNotIn("birthday", p.changed_data)
|
||||||
|
|
||||||
# A field raising ValidationError is always in changed_data
|
# A field raising ValidationError is always in changed_data
|
||||||
class PedanticField(forms.Field):
|
class PedanticField(Field):
|
||||||
def to_python(self, value):
|
def to_python(self, value):
|
||||||
raise ValidationError("Whatever")
|
raise ValidationError("Whatever")
|
||||||
|
|
||||||
@ -2879,7 +2879,7 @@ Options: <select multiple name="options" aria-invalid="true" required>
|
|||||||
microseconds,
|
microseconds,
|
||||||
)
|
)
|
||||||
|
|
||||||
class DateTimeForm(forms.Form):
|
class DateTimeForm(Form):
|
||||||
dt = DateTimeField(initial=FakeTime().now, disabled=disabled)
|
dt = DateTimeField(initial=FakeTime().now, disabled=disabled)
|
||||||
|
|
||||||
return DateTimeForm({})
|
return DateTimeForm({})
|
||||||
@ -2914,7 +2914,7 @@ Options: <select multiple name="options" aria-invalid="true" required>
|
|||||||
self.assertEqual(cleaned, bf.initial)
|
self.assertEqual(cleaned, bf.initial)
|
||||||
|
|
||||||
def test_datetime_changed_data_callable_with_microseconds(self):
|
def test_datetime_changed_data_callable_with_microseconds(self):
|
||||||
class DateTimeForm(forms.Form):
|
class DateTimeForm(Form):
|
||||||
dt = DateTimeField(
|
dt = DateTimeField(
|
||||||
initial=lambda: datetime.datetime(2006, 10, 25, 14, 30, 45, 123456),
|
initial=lambda: datetime.datetime(2006, 10, 25, 14, 30, 45, 123456),
|
||||||
disabled=True,
|
disabled=True,
|
||||||
@ -3570,8 +3570,8 @@ Options: <select multiple name="options" aria-invalid="true" required>
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_filefield_initial_callable(self):
|
def test_filefield_initial_callable(self):
|
||||||
class FileForm(forms.Form):
|
class FileForm(Form):
|
||||||
file1 = forms.FileField(initial=lambda: "resume.txt")
|
file1 = FileField(initial=lambda: "resume.txt")
|
||||||
|
|
||||||
f = FileForm({})
|
f = FileForm({})
|
||||||
self.assertEqual(f.errors, {})
|
self.assertEqual(f.errors, {})
|
||||||
@ -3579,7 +3579,7 @@ Options: <select multiple name="options" aria-invalid="true" required>
|
|||||||
|
|
||||||
def test_filefield_with_fileinput_required(self):
|
def test_filefield_with_fileinput_required(self):
|
||||||
class FileForm(Form):
|
class FileForm(Form):
|
||||||
file1 = forms.FileField(widget=FileInput)
|
file1 = FileField(widget=FileInput)
|
||||||
|
|
||||||
f = FileForm(auto_id=False)
|
f = FileForm(auto_id=False)
|
||||||
self.assertHTMLEqual(
|
self.assertHTMLEqual(
|
||||||
@ -4057,7 +4057,7 @@ Options: <select multiple name="options" aria-invalid="true" required>
|
|||||||
return {}
|
return {}
|
||||||
return super().to_python(value)
|
return super().to_python(value)
|
||||||
|
|
||||||
class JSONForm(forms.Form):
|
class JSONForm(Form):
|
||||||
json = CustomJSONField()
|
json = CustomJSONField()
|
||||||
|
|
||||||
form = JSONForm(data={"json": "{}"})
|
form = JSONForm(data={"json": "{}"})
|
||||||
|
Loading…
Reference in New Issue
Block a user