Skip to content

Commit

Permalink
Add new names for assert functions from Django 4.2 (#1365)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamchainz authored Feb 18, 2023
1 parent cf8c0a6 commit 2684efe
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions django-stubs/test/testcases.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,15 @@ 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,
field: str | None,
errors: list[str] | str,
msg_prefix: str = ...,
) -> None: ...
# assertFormsetError (lowercase "set") deprecated in Django 4.2
@overload
def assertFormsetError(
self,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit 2684efe

Please sign in to comment.