From c5c6d311e1b9ac099881acb10e1e4897c9fb8724 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sun, 14 Aug 2022 18:07:20 +0100 Subject: [PATCH] Add different signatures for form assertions from Django 4.1 --- django-stubs/test/testcases.pyi | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/django-stubs/test/testcases.pyi b/django-stubs/test/testcases.pyi index 40b0199ebb..327c806299 100644 --- a/django-stubs/test/testcases.pyi +++ b/django-stubs/test/testcases.pyi @@ -25,6 +25,7 @@ from django.db import connections as connections # noqa: F401 from django.db.backends.base.base import BaseDatabaseWrapper from django.db.models.base import Model from django.db.models.query import QuerySet, RawQuerySet +from django.forms import Form, Formset from django.forms.fields import EmailField from django.http.response import FileResponse, HttpResponseBase from django.template.base import Template @@ -99,6 +100,15 @@ class SimpleTestCase(unittest.TestCase): msg_prefix: str = ..., html: bool = ..., ) -> None: ... + @overload + def assertFormError( + self, + form: Form, + field: Optional[str], + errors: Union[List[str], str], + msg_prefix: str = ..., + ) -> None: ... + @overload def assertFormError( self, response: HttpResponseBase, @@ -107,6 +117,16 @@ class SimpleTestCase(unittest.TestCase): errors: Union[List[str], str], msg_prefix: str = ..., ) -> None: ... + @overload + def assertFormsetError( + self, + formset: Formset, + form_index: Optional[int], + field: Optional[str], + errors: Union[List[str], str], + msg_prefix: str = ..., + ) -> None: ... + @overload def assertFormsetError( self, response: HttpResponseBase,