mirror of
https://github.com/davidhalter/django-stubs.git
synced 2026-08-13 11:21:05 +08:00
Update SimpleTestCase.assert method response types (#942)
Since PR 909, SimpleTestCase.client.get() etc methods return a class that no longer derives from `HttpResponse`, but instead `HttpResponseBase`, the `assert*` methods taking response should be updated as well. Discovered while trying to update djangorestframework-stubs to django-stubs as of master.
This commit is contained in:
@@ -32,7 +32,6 @@ from django.test.client import AsyncClient, Client
|
|||||||
from django.test.html import Element
|
from django.test.html import Element
|
||||||
from django.test.utils import CaptureQueriesContext, ContextList
|
from django.test.utils import CaptureQueriesContext, ContextList
|
||||||
from django.utils.functional import classproperty
|
from django.utils.functional import classproperty
|
||||||
from django.utils.safestring import SafeString
|
|
||||||
|
|
||||||
def to_list(value: Any) -> list[Any]: ...
|
def to_list(value: Any) -> list[Any]: ...
|
||||||
def assert_and_parse_html(self: Any, html: str, user_msg: str, msg: str) -> Element: ...
|
def assert_and_parse_html(self: Any, html: str, user_msg: str, msg: str) -> Element: ...
|
||||||
@@ -76,7 +75,7 @@ class SimpleTestCase(unittest.TestCase):
|
|||||||
def modify_settings(self, **kwargs: Any) -> Any: ...
|
def modify_settings(self, **kwargs: Any) -> Any: ...
|
||||||
def assertRedirects(
|
def assertRedirects(
|
||||||
self,
|
self,
|
||||||
response: HttpResponse,
|
response: HttpResponseBase,
|
||||||
expected_url: str,
|
expected_url: str,
|
||||||
status_code: int = ...,
|
status_code: int = ...,
|
||||||
target_status_code: int = ...,
|
target_status_code: int = ...,
|
||||||
@@ -94,7 +93,7 @@ class SimpleTestCase(unittest.TestCase):
|
|||||||
) -> None: ...
|
) -> None: ...
|
||||||
def assertNotContains(
|
def assertNotContains(
|
||||||
self,
|
self,
|
||||||
response: HttpResponse,
|
response: HttpResponseBase,
|
||||||
text: Union[bytes, str],
|
text: Union[bytes, str],
|
||||||
status_code: int = ...,
|
status_code: int = ...,
|
||||||
msg_prefix: str = ...,
|
msg_prefix: str = ...,
|
||||||
@@ -102,7 +101,7 @@ class SimpleTestCase(unittest.TestCase):
|
|||||||
) -> None: ...
|
) -> None: ...
|
||||||
def assertFormError(
|
def assertFormError(
|
||||||
self,
|
self,
|
||||||
response: HttpResponse,
|
response: HttpResponseBase,
|
||||||
form: str,
|
form: str,
|
||||||
field: Optional[str],
|
field: Optional[str],
|
||||||
errors: Union[List[str], str],
|
errors: Union[List[str], str],
|
||||||
@@ -110,7 +109,7 @@ class SimpleTestCase(unittest.TestCase):
|
|||||||
) -> None: ...
|
) -> None: ...
|
||||||
def assertFormsetError(
|
def assertFormsetError(
|
||||||
self,
|
self,
|
||||||
response: HttpResponse,
|
response: HttpResponseBase,
|
||||||
formset: str,
|
formset: str,
|
||||||
form_index: Optional[int],
|
form_index: Optional[int],
|
||||||
field: Optional[str],
|
field: Optional[str],
|
||||||
@@ -119,13 +118,13 @@ class SimpleTestCase(unittest.TestCase):
|
|||||||
) -> None: ...
|
) -> None: ...
|
||||||
def assertTemplateUsed(
|
def assertTemplateUsed(
|
||||||
self,
|
self,
|
||||||
response: Optional[Union[HttpResponse, str]] = ...,
|
response: Optional[Union[HttpResponseBase, str]] = ...,
|
||||||
template_name: Optional[str] = ...,
|
template_name: Optional[str] = ...,
|
||||||
msg_prefix: str = ...,
|
msg_prefix: str = ...,
|
||||||
count: Optional[int] = ...,
|
count: Optional[int] = ...,
|
||||||
) -> Optional[_AssertTemplateUsedContext]: ...
|
) -> Optional[_AssertTemplateUsedContext]: ...
|
||||||
def assertTemplateNotUsed(
|
def assertTemplateNotUsed(
|
||||||
self, response: Union[HttpResponse, str] = ..., template_name: Optional[str] = ..., msg_prefix: str = ...
|
self, response: Union[HttpResponseBase, str] = ..., template_name: Optional[str] = ..., msg_prefix: str = ...
|
||||||
) -> Optional[_AssertTemplateNotUsedContext]: ...
|
) -> Optional[_AssertTemplateNotUsedContext]: ...
|
||||||
def assertRaisesMessage(
|
def assertRaisesMessage(
|
||||||
self, expected_exception: Type[Exception], expected_message: str, *args: Any, **kwargs: Any
|
self, expected_exception: Type[Exception], expected_message: str, *args: Any, **kwargs: Any
|
||||||
|
|||||||
Reference in New Issue
Block a user