mirror of
https://github.com/django/django.git
synced 2025-01-03 15:06:09 +00:00
Refs #33348 -- Removed support for passing errors=None to SimpleTestCase.assertFormError()/assertFormsetErrors().
Per deprecation timeline.
This commit is contained in:
parent
23ec318988
commit
23c8787439
@ -724,15 +724,6 @@ class SimpleTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
You can pass field=None to check the form's non-field errors.
|
You can pass field=None to check the form's non-field errors.
|
||||||
"""
|
"""
|
||||||
if errors is None:
|
|
||||||
warnings.warn(
|
|
||||||
"Passing errors=None to assertFormError() is deprecated, use "
|
|
||||||
"errors=[] instead.",
|
|
||||||
RemovedInDjango50Warning,
|
|
||||||
stacklevel=2,
|
|
||||||
)
|
|
||||||
errors = []
|
|
||||||
|
|
||||||
if msg_prefix:
|
if msg_prefix:
|
||||||
msg_prefix += ": "
|
msg_prefix += ": "
|
||||||
errors = to_list(errors)
|
errors = to_list(errors)
|
||||||
@ -760,15 +751,6 @@ class SimpleTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
Other parameters are the same as assertFormError().
|
Other parameters are the same as assertFormError().
|
||||||
"""
|
"""
|
||||||
if errors is None:
|
|
||||||
warnings.warn(
|
|
||||||
"Passing errors=None to assertFormSetError() is deprecated, "
|
|
||||||
"use errors=[] instead.",
|
|
||||||
RemovedInDjango50Warning,
|
|
||||||
stacklevel=2,
|
|
||||||
)
|
|
||||||
errors = []
|
|
||||||
|
|
||||||
if form_index is None and field is not None:
|
if form_index is None and field is not None:
|
||||||
raise ValueError("You must use field=None with form_index=None.")
|
raise ValueError("You must use field=None with form_index=None.")
|
||||||
|
|
||||||
|
@ -314,3 +314,6 @@ to remove usage of these features.
|
|||||||
|
|
||||||
* The ``opclasses`` argument of
|
* The ``opclasses`` argument of
|
||||||
``django.contrib.postgres.constraints.ExclusionConstraint`` is removed.
|
``django.contrib.postgres.constraints.ExclusionConstraint`` is removed.
|
||||||
|
|
||||||
|
* The undocumented ability to pass ``errors=None`` to
|
||||||
|
``SimpleTestCase.assertFormError()`` and ``assertFormsetError()`` is removed.
|
||||||
|
@ -1769,23 +1769,6 @@ class AssertFormErrorDeprecationTests(SimpleTestCase):
|
|||||||
signature.
|
signature.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ignore_warnings(category=RemovedInDjango50Warning)
|
|
||||||
def test_assert_form_error_errors_none(self):
|
|
||||||
msg = (
|
|
||||||
"The errors of field 'field' on form <TestForm bound=True, valid=False, "
|
|
||||||
"fields=(field)> don't match."
|
|
||||||
)
|
|
||||||
with self.assertRaisesMessage(AssertionError, msg):
|
|
||||||
self.assertFormError(TestForm.invalid(), "field", None)
|
|
||||||
|
|
||||||
def test_assert_form_error_errors_none_warning(self):
|
|
||||||
msg = (
|
|
||||||
"Passing errors=None to assertFormError() is deprecated, use "
|
|
||||||
"errors=[] instead."
|
|
||||||
)
|
|
||||||
with self.assertWarnsMessage(RemovedInDjango50Warning, msg):
|
|
||||||
self.assertFormError(TestForm.valid(), "field", None)
|
|
||||||
|
|
||||||
def _assert_form_error_old_api_cases(self, form, field, errors, msg_prefix):
|
def _assert_form_error_old_api_cases(self, form, field, errors, msg_prefix):
|
||||||
response = mock.Mock(context=[{"form": TestForm.invalid()}])
|
response = mock.Mock(context=[{"form": TestForm.invalid()}])
|
||||||
return (
|
return (
|
||||||
@ -1852,23 +1835,6 @@ class AssertFormErrorDeprecationTests(SimpleTestCase):
|
|||||||
with self.assertRaises(AssertionError):
|
with self.assertRaises(AssertionError):
|
||||||
self.assertFormError(*args, **kwargs)
|
self.assertFormError(*args, **kwargs)
|
||||||
|
|
||||||
@ignore_warnings(category=RemovedInDjango50Warning)
|
|
||||||
def test_assert_formset_error_errors_none(self):
|
|
||||||
msg = (
|
|
||||||
"The errors of field 'field' on form 0 of formset <TestFormset: bound=True "
|
|
||||||
"valid=False total_forms=1> don't match."
|
|
||||||
)
|
|
||||||
with self.assertRaisesMessage(AssertionError, msg):
|
|
||||||
self.assertFormSetError(TestFormset.invalid(), 0, "field", None)
|
|
||||||
|
|
||||||
def test_assert_formset_error_errors_none_warning(self):
|
|
||||||
msg = (
|
|
||||||
"Passing errors=None to assertFormSetError() is deprecated, use "
|
|
||||||
"errors=[] instead."
|
|
||||||
)
|
|
||||||
with self.assertWarnsMessage(RemovedInDjango50Warning, msg):
|
|
||||||
self.assertFormSetError(TestFormset.valid(), 0, "field", None)
|
|
||||||
|
|
||||||
def _assert_formset_error_old_api_cases(
|
def _assert_formset_error_old_api_cases(
|
||||||
self, formset, form_index, field, errors, msg_prefix
|
self, formset, form_index, field, errors, msg_prefix
|
||||||
):
|
):
|
||||||
|
Loading…
Reference in New Issue
Block a user