From a3cc0be78f4890b8228eb69da6058b6fe534a15c Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Thu, 9 Feb 2023 15:55:02 +0000 Subject: [PATCH] Add new names for assert functions from Django 4.2 --- django-stubs/test/testcases.pyi | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/django-stubs/test/testcases.pyi b/django-stubs/test/testcases.pyi index 62eac1a1a..0a88529e4 100644 --- a/django-stubs/test/testcases.pyi +++ b/django-stubs/test/testcases.pyi @@ -109,7 +109,7 @@ class SimpleTestCase(unittest.TestCase): msg_prefix: str = ..., ) -> None: ... @overload - def assertFormError( + def assertFormError( # old signature, deprecated in Django 4.1 self, response: HttpResponseBase, form: str, @@ -117,6 +117,7 @@ class SimpleTestCase(unittest.TestCase): errors: list[str] | str, msg_prefix: str = ..., ) -> None: ... + # assertFormsetError (lowercase "set") deprecated in Django 4.2 @overload def assertFormsetError( self, @@ -127,7 +128,26 @@ class SimpleTestCase(unittest.TestCase): msg_prefix: str = ..., ) -> None: ... @overload - def assertFormsetError( + def assertFormsetError( # old signature, deprecated in Django 4.1 + self, + response: HttpResponseBase, + formset: str, + form_index: int | None, + field: str | None, + errors: list[str] | str, + msg_prefix: str = ..., + ) -> None: ... + @overload + def assertFormSetError( + self, + formset: BaseFormSet, + form_index: int | None, + field: str | None, + errors: list[str] | str, + msg_prefix: str = ..., + ) -> None: ... + @overload + def assertFormSetError( self, response: HttpResponseBase, formset: str, @@ -185,6 +205,7 @@ class TransactionTestCase(SimpleTestCase): fixtures: Any multi_db: bool serialized_rollback: bool + # assertQuerysetEqual (lowercase "set") deprecated in Django 4.2 def assertQuerysetEqual( self, qs: Iterator[Any] | list[Model] | QuerySet | RawQuerySet, @@ -193,6 +214,14 @@ class TransactionTestCase(SimpleTestCase): ordered: bool = ..., msg: str | None = ..., ) -> None: ... + def assertQuerySetEqual( + self, + qs: Iterator[Any] | list[Model] | QuerySet | RawQuerySet, + values: Collection[Any], + transform: Callable[[Model], Any] | type[str] = ..., + ordered: bool = ..., + msg: str | None = ..., + ) -> None: ... @overload def assertNumQueries(self, num: int, using: str = ...) -> _AssertNumQueriesContext: ... # type: ignore @overload