mirror of
https://github.com/davidhalter/django-stubs.git
synced 2026-10-25 23:27:38 +08:00
third iteration of stubs
This commit is contained in:
1 parent
fa718b8e55
commit
c6bceb19f4
216 files changed
+16306
-3006
No files matched your search
+133
-25
@@ -1,11 +1,15 @@
|
||||
from datetime import date
|
||||
from io import BufferedRandom, BufferedReader, BytesIO, StringIO
|
||||
from tempfile import _TemporaryFileWrapper
|
||||
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.sessions.backends.base import SessionBase
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.core.handlers.base import BaseHandler
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.dispatch.dispatcher import Signal
|
||||
from django.http.request import HttpRequest, QueryDict
|
||||
from django.http.request import HttpRequest
|
||||
from django.http.response import (HttpResponse, HttpResponseBase,
|
||||
HttpResponseRedirect)
|
||||
from django.template.base import Template
|
||||
@@ -22,20 +26,72 @@ class RedirectCycleError(Exception):
|
||||
|
||||
class FakePayload:
|
||||
read_started: bool = ...
|
||||
def __init__(self, content: Optional[Union[str, bytes]] = ...) -> None: ...
|
||||
def __init__(self, content: Optional[Union[bytes, str]] = ...) -> None: ...
|
||||
def __len__(self) -> int: ...
|
||||
def read(self, num_bytes: int = ...) -> bytes: ...
|
||||
def write(self, content: Union[str, bytes]) -> None: ...
|
||||
def write(self, content: Union[bytes, str]) -> None: ...
|
||||
|
||||
class ClientHandler(BaseHandler):
|
||||
enforce_csrf_checks: bool = ...
|
||||
def __init__(
|
||||
self, enforce_csrf_checks: bool = ..., *args: Any, **kwargs: Any
|
||||
) -> None: ...
|
||||
def __call__(self, environ: Dict[str, Any]) -> HttpResponseBase: ...
|
||||
def __call__(
|
||||
self,
|
||||
environ: Union[
|
||||
Dict[
|
||||
str,
|
||||
Optional[
|
||||
Union[Tuple[int, int], BytesIO, FakePayload, int, str]
|
||||
],
|
||||
],
|
||||
Dict[
|
||||
str,
|
||||
Union[
|
||||
Dict[str, str],
|
||||
Tuple[int, int],
|
||||
BytesIO,
|
||||
FakePayload,
|
||||
int,
|
||||
str,
|
||||
],
|
||||
],
|
||||
],
|
||||
) -> HttpResponseBase: ...
|
||||
|
||||
def encode_multipart(boundary: str, data: Dict[str, Any]) -> bytes: ...
|
||||
def encode_file(boundary: str, key: str, file: Any) -> List[bytes]: ...
|
||||
def encode_multipart(
|
||||
boundary: str,
|
||||
data: Union[
|
||||
Dict[str, Union[List[int], List[str], int]],
|
||||
Dict[str, Union[List[int], int, str]],
|
||||
Dict[str, Union[List[str], int, str]],
|
||||
Dict[str, Union[Tuple[str, str, str], int, str]],
|
||||
Dict[
|
||||
str,
|
||||
Union[
|
||||
Tuple[_TemporaryFileWrapper, _TemporaryFileWrapper],
|
||||
str,
|
||||
_TemporaryFileWrapper,
|
||||
],
|
||||
],
|
||||
Dict[str, Union[BufferedReader, str]],
|
||||
Dict[str, Union[BytesIO, StringIO, _TemporaryFileWrapper]],
|
||||
Dict[str, BufferedRandom],
|
||||
Dict[str, SimpleUploadedFile],
|
||||
],
|
||||
) -> bytes: ...
|
||||
def encode_file(
|
||||
boundary: str,
|
||||
key: str,
|
||||
file: Union[
|
||||
BufferedRandom,
|
||||
BufferedReader,
|
||||
BytesIO,
|
||||
StringIO,
|
||||
SimpleUploadedFile,
|
||||
_TemporaryFileWrapper,
|
||||
],
|
||||
) -> List[bytes]: ...
|
||||
|
||||
class RequestFactory:
|
||||
json_encoder: Type[django.core.serializers.json.DjangoJSONEncoder] = ...
|
||||
@@ -45,12 +101,44 @@ class RequestFactory:
|
||||
def __init__(self, *, json_encoder: Any = ..., **defaults: Any) -> None: ...
|
||||
def request(self, **request: Any) -> WSGIRequest: ...
|
||||
def get(
|
||||
self, path: str, data: Any = ..., secure: bool = ..., **extra: Any
|
||||
self,
|
||||
path: str,
|
||||
data: Optional[
|
||||
Union[
|
||||
Dict[str, Union[Tuple[str, str, str], str]],
|
||||
Dict[str, Union[int, str]],
|
||||
Dict[str, date],
|
||||
str,
|
||||
]
|
||||
] = ...,
|
||||
secure: bool = ...,
|
||||
**extra: Any
|
||||
) -> Union[WSGIRequest, HttpResponseBase]: ...
|
||||
def post(
|
||||
self,
|
||||
path: str,
|
||||
data: Any = ...,
|
||||
data: Optional[
|
||||
Union[
|
||||
Dict[str, Union[List[int], List[str], int]],
|
||||
Dict[str, Union[List[int], int, str]],
|
||||
Dict[str, Union[List[str], int, str]],
|
||||
Dict[str, Union[Tuple[str, str, str], int, str]],
|
||||
Dict[
|
||||
str,
|
||||
Union[
|
||||
Tuple[_TemporaryFileWrapper, _TemporaryFileWrapper],
|
||||
str,
|
||||
_TemporaryFileWrapper,
|
||||
],
|
||||
],
|
||||
Dict[str, Union[BufferedReader, str]],
|
||||
Dict[str, Union[BytesIO, StringIO, _TemporaryFileWrapper]],
|
||||
Dict[str, BufferedRandom],
|
||||
Dict[str, SimpleUploadedFile],
|
||||
bytes,
|
||||
str,
|
||||
]
|
||||
] = ...,
|
||||
content_type: str = ...,
|
||||
secure: bool = ...,
|
||||
**extra: Any
|
||||
@@ -58,7 +146,7 @@ class RequestFactory:
|
||||
def head(
|
||||
self,
|
||||
path: str,
|
||||
data: Optional[Union[str, Dict[str, str]]] = ...,
|
||||
data: Optional[Union[Dict[str, str], str]] = ...,
|
||||
secure: bool = ...,
|
||||
**extra: Any
|
||||
) -> Union[WSGIRequest, HttpResponse]: ...
|
||||
@@ -68,7 +156,7 @@ class RequestFactory:
|
||||
def options(
|
||||
self,
|
||||
path: str,
|
||||
data: Union[str, Dict[str, str]] = ...,
|
||||
data: Union[Dict[str, str], str] = ...,
|
||||
content_type: str = ...,
|
||||
secure: bool = ...,
|
||||
**extra: Any
|
||||
@@ -76,7 +164,7 @@ class RequestFactory:
|
||||
def put(
|
||||
self,
|
||||
path: str,
|
||||
data: Union[str, bytes, Dict[str, str], Dict[str, int]] = ...,
|
||||
data: Union[Dict[str, int], Dict[str, str], bytes, str] = ...,
|
||||
content_type: str = ...,
|
||||
secure: bool = ...,
|
||||
**extra: Any
|
||||
@@ -84,7 +172,7 @@ class RequestFactory:
|
||||
def patch(
|
||||
self,
|
||||
path: str,
|
||||
data: Union[str, Dict[str, str], Dict[str, int]] = ...,
|
||||
data: Union[Dict[str, int], Dict[str, str], str] = ...,
|
||||
content_type: str = ...,
|
||||
secure: bool = ...,
|
||||
**extra: Any
|
||||
@@ -92,7 +180,7 @@ class RequestFactory:
|
||||
def delete(
|
||||
self,
|
||||
path: str,
|
||||
data: Union[str, Dict[str, str], Dict[str, int]] = ...,
|
||||
data: Union[Dict[str, int], Dict[str, str], str] = ...,
|
||||
content_type: str = ...,
|
||||
secure: bool = ...,
|
||||
**extra: Any
|
||||
@@ -101,7 +189,7 @@ class RequestFactory:
|
||||
self,
|
||||
method: str,
|
||||
path: str,
|
||||
data: Union[str, bytes, Dict[str, str]] = ...,
|
||||
data: Union[Dict[str, str], bytes, str] = ...,
|
||||
content_type: Optional[str] = ...,
|
||||
secure: bool = ...,
|
||||
**extra: Any
|
||||
@@ -111,8 +199,8 @@ class Client(RequestFactory):
|
||||
defaults: Dict[str, str]
|
||||
errors: _io.BytesIO
|
||||
json_encoder: Union[
|
||||
unittest.mock.MagicMock,
|
||||
Type[django.core.serializers.json.DjangoJSONEncoder],
|
||||
unittest.mock.MagicMock,
|
||||
]
|
||||
handler: django.test.client.ClientHandler = ...
|
||||
exc_info: None = ...
|
||||
@@ -128,10 +216,9 @@ class Client(RequestFactory):
|
||||
path: str,
|
||||
data: Optional[
|
||||
Union[
|
||||
Dict[str, Union[str, int]],
|
||||
QueryDict,
|
||||
Dict[str, Union[Tuple[str, str, str], str]],
|
||||
Dict[str, Union[int, str]],
|
||||
str,
|
||||
Dict[str, Union[str, Tuple[str, str, str]]],
|
||||
]
|
||||
] = ...,
|
||||
follow: bool = ...,
|
||||
@@ -141,7 +228,28 @@ class Client(RequestFactory):
|
||||
def post(
|
||||
self,
|
||||
path: str,
|
||||
data: Any = ...,
|
||||
data: Optional[
|
||||
Union[
|
||||
Dict[str, Union[List[int], List[str], int]],
|
||||
Dict[str, Union[List[int], int, str]],
|
||||
Dict[str, Union[List[str], int, str]],
|
||||
Dict[str, Union[Tuple[str, str, str], int, str]],
|
||||
Dict[
|
||||
str,
|
||||
Union[
|
||||
Tuple[_TemporaryFileWrapper, _TemporaryFileWrapper],
|
||||
str,
|
||||
_TemporaryFileWrapper,
|
||||
],
|
||||
],
|
||||
Dict[str, Union[BufferedReader, str]],
|
||||
Dict[str, Union[BytesIO, StringIO, _TemporaryFileWrapper]],
|
||||
Dict[str, BufferedRandom],
|
||||
Dict[str, SimpleUploadedFile],
|
||||
bytes,
|
||||
str,
|
||||
]
|
||||
] = ...,
|
||||
content_type: str = ...,
|
||||
follow: bool = ...,
|
||||
secure: bool = ...,
|
||||
@@ -150,7 +258,7 @@ class Client(RequestFactory):
|
||||
def head(
|
||||
self,
|
||||
path: str,
|
||||
data: Optional[Union[str, Dict[str, str]]] = ...,
|
||||
data: Optional[Union[Dict[str, str], str]] = ...,
|
||||
follow: bool = ...,
|
||||
secure: bool = ...,
|
||||
**extra: Any
|
||||
@@ -158,7 +266,7 @@ class Client(RequestFactory):
|
||||
def options(
|
||||
self,
|
||||
path: str,
|
||||
data: Union[str, Dict[str, str]] = ...,
|
||||
data: Union[Dict[str, str], str] = ...,
|
||||
content_type: str = ...,
|
||||
follow: bool = ...,
|
||||
secure: bool = ...,
|
||||
@@ -167,7 +275,7 @@ class Client(RequestFactory):
|
||||
def put(
|
||||
self,
|
||||
path: str,
|
||||
data: Union[str, bytes, Dict[str, str], Dict[str, int]] = ...,
|
||||
data: Union[Dict[str, int], Dict[str, str], bytes, str] = ...,
|
||||
content_type: str = ...,
|
||||
follow: bool = ...,
|
||||
secure: bool = ...,
|
||||
@@ -176,7 +284,7 @@ class Client(RequestFactory):
|
||||
def patch(
|
||||
self,
|
||||
path: str,
|
||||
data: Union[str, Dict[str, str], Dict[str, int]] = ...,
|
||||
data: Union[Dict[str, int], Dict[str, str], str] = ...,
|
||||
content_type: str = ...,
|
||||
follow: bool = ...,
|
||||
secure: bool = ...,
|
||||
@@ -185,7 +293,7 @@ class Client(RequestFactory):
|
||||
def delete(
|
||||
self,
|
||||
path: str,
|
||||
data: Union[str, Dict[str, str], Dict[str, int]] = ...,
|
||||
data: Union[Dict[str, int], Dict[str, str], str] = ...,
|
||||
content_type: str = ...,
|
||||
follow: bool = ...,
|
||||
secure: bool = ...,
|
||||
@@ -194,7 +302,7 @@ class Client(RequestFactory):
|
||||
def trace(
|
||||
self,
|
||||
path: str,
|
||||
data: Union[str, Dict[str, str]] = ...,
|
||||
data: Union[Dict[str, str], str] = ...,
|
||||
follow: bool = ...,
|
||||
secure: bool = ...,
|
||||
**extra: Any
|
||||
|
||||
@@ -7,20 +7,22 @@ def normalize_whitespace(string: str) -> str: ...
|
||||
|
||||
class Element:
|
||||
name: str = ...
|
||||
attributes: List[Tuple[str, Optional[str]]] = ...
|
||||
attributes: List[Union[Tuple[str, None], Tuple[str, str]]] = ...
|
||||
children: List[Union[django.test.html.Element, str]] = ...
|
||||
def __init__(
|
||||
self,
|
||||
name: Optional[str],
|
||||
attributes: Union[List[Tuple[str, Union[str, None]]], Tuple],
|
||||
attributes: Union[
|
||||
List[Union[Tuple[str, None], Tuple[str, str]]], Tuple
|
||||
],
|
||||
) -> None: ...
|
||||
def append(self, element: Union[str, Element]) -> None: ...
|
||||
def append(self, element: Union[Element, str]) -> None: ...
|
||||
def finalize(self) -> None: ...
|
||||
def __eq__(self, element: Element) -> bool: ...
|
||||
def __hash__(self) -> int: ...
|
||||
def __contains__(self, element: Union[str, Element]) -> bool: ...
|
||||
def count(self, element: Union[str, Element]) -> int: ...
|
||||
def __getitem__(self, key: int) -> Union[str, Element]: ...
|
||||
def __contains__(self, element: Union[Element, str]) -> bool: ...
|
||||
def count(self, element: Union[Element, str]) -> int: ...
|
||||
def __getitem__(self, key: int) -> Union[Element, str]: ...
|
||||
|
||||
class RootElement(Element):
|
||||
attributes: List[Any]
|
||||
@@ -43,10 +45,10 @@ class Parser(HTMLParser):
|
||||
@property
|
||||
def current(self) -> Element: ...
|
||||
def handle_startendtag(
|
||||
self, tag: str, attrs: List[Tuple[str, Optional[str]]]
|
||||
self, tag: str, attrs: List[Union[Tuple[str, None], Tuple[str, str]]]
|
||||
) -> None: ...
|
||||
def handle_starttag(
|
||||
self, tag: str, attrs: List[Tuple[str, Optional[str]]]
|
||||
self, tag: str, attrs: List[Union[Tuple[str, None], Tuple[str, str]]]
|
||||
) -> None: ...
|
||||
def handle_endtag(self, tag: str) -> None: ...
|
||||
def handle_data(self, data: str) -> None: ...
|
||||
|
||||
@@ -14,10 +14,20 @@ class DebugSQLTextTestResult(unittest.TextTestResult):
|
||||
buffer: bool
|
||||
descriptions: bool
|
||||
dots: bool
|
||||
errors: List[Tuple[unittest.case.TestCase, str, str]]
|
||||
errors: List[
|
||||
Union[
|
||||
Tuple[django.test.testcases.TestCase, str, str],
|
||||
Tuple[unittest.case._SubTest, str, str],
|
||||
]
|
||||
]
|
||||
expectedFailures: List[Any]
|
||||
failfast: bool
|
||||
failures: List[Tuple[unittest.case.TestCase, str, str]]
|
||||
failures: List[
|
||||
Union[
|
||||
Tuple[django.test.testcases.TestCase, str, str],
|
||||
Tuple[unittest.case._SubTest, str, str],
|
||||
]
|
||||
]
|
||||
shouldStop: bool
|
||||
showAll: bool
|
||||
skipped: List[Any]
|
||||
@@ -127,7 +137,7 @@ class DiscoverRunner:
|
||||
def setup_test_environment(self, **kwargs: Any) -> None: ...
|
||||
def build_suite(
|
||||
self,
|
||||
test_labels: Union[Tuple[str, str], List[str]] = ...,
|
||||
test_labels: Union[List[str], Tuple[str, str]] = ...,
|
||||
extra_tests: Optional[List[Any]] = ...,
|
||||
**kwargs: Any
|
||||
) -> TestSuite: ...
|
||||
|
||||
@@ -10,7 +10,7 @@ class SeleniumTestCaseBase:
|
||||
cls: Type[SeleniumTestCaseBase],
|
||||
name: str,
|
||||
bases: Tuple[Type[SeleniumTestCase]],
|
||||
attrs: Dict[str, Union[str, List[str], Callable]],
|
||||
attrs: Dict[str, Union[Callable, List[str], str]],
|
||||
) -> Type[SeleniumTestCase]: ...
|
||||
@classmethod
|
||||
def import_webdriver(cls, browser: Any): ...
|
||||
|
||||
+121
-58
@@ -1,17 +1,28 @@
|
||||
import threading
|
||||
import unittest
|
||||
from contextlib import _GeneratorContextManager
|
||||
from typing import Any, Callable, List, Optional, Tuple, Type, Union
|
||||
from datetime import date, time, timedelta
|
||||
from decimal import Decimal
|
||||
from typing import (Any, Callable, Dict, Iterator, List, Optional, Set, Tuple,
|
||||
Type, Union)
|
||||
from unittest.runner import TextTestResult
|
||||
from uuid import UUID
|
||||
|
||||
from django.contrib.staticfiles.handlers import StaticFilesHandler
|
||||
from django.core.handlers.wsgi import WSGIHandler
|
||||
from django.core.management.commands.dumpdata import ProxyModelWarning
|
||||
from django.core.servers.basehttp import WSGIRequestHandler
|
||||
from django.db.backends.sqlite3.base import DatabaseWrapper
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.query import QuerySet
|
||||
from django.http.response import HttpResponse
|
||||
from django.template.response import TemplateResponse
|
||||
from django.db.models.query import QuerySet, RawQuerySet
|
||||
from django.forms.fields import EmailField
|
||||
from django.http.response import HttpResponse, HttpResponseBase
|
||||
from django.template.context import Context
|
||||
from django.test.html import Element
|
||||
from django.test.utils import CaptureQueriesContext, override_settings
|
||||
from django.test.utils import (Approximate, CaptureQueriesContext,
|
||||
modify_settings, override_settings)
|
||||
from django.utils.deprecation import RemovedInDjango30Warning
|
||||
from django.utils.safestring import SafeText
|
||||
|
||||
|
||||
class _AssertNumQueriesContext(CaptureQueriesContext):
|
||||
@@ -20,8 +31,8 @@ class _AssertNumQueriesContext(CaptureQueriesContext):
|
||||
force_debug_cursor: bool
|
||||
initial_queries: int
|
||||
test_case: Union[
|
||||
django.test.testcases.TransactionTestCase,
|
||||
django.test.testcases.SerializeMixin,
|
||||
django.test.testcases.TransactionTestCase,
|
||||
] = ...
|
||||
num: int = ...
|
||||
def __init__(self, test_case: Any, num: Any, connection: Any) -> None: ...
|
||||
@@ -71,7 +82,7 @@ class SimpleTestCase(unittest.TestCase):
|
||||
def tearDownClass(cls) -> None: ...
|
||||
def __call__(self, result: TextTestResult = ...) -> None: ...
|
||||
def settings(self, **kwargs: Any) -> override_settings: ...
|
||||
def modify_settings(self, **kwargs: Any): ...
|
||||
def modify_settings(self, **kwargs: Any) -> modify_settings: ...
|
||||
def assertRedirects(
|
||||
self,
|
||||
response: HttpResponse,
|
||||
@@ -83,98 +94,107 @@ class SimpleTestCase(unittest.TestCase):
|
||||
) -> None: ...
|
||||
def assertContains(
|
||||
self,
|
||||
response: HttpResponse,
|
||||
text: Union[str, bytes],
|
||||
count: None = ...,
|
||||
response: HttpResponseBase,
|
||||
text: Union[bytes, int, str],
|
||||
count: Optional[int] = ...,
|
||||
status_code: int = ...,
|
||||
msg_prefix: str = ...,
|
||||
html: bool = ...,
|
||||
) -> None: ...
|
||||
def assertNotContains(
|
||||
self,
|
||||
response: TemplateResponse,
|
||||
text: str,
|
||||
response: HttpResponse,
|
||||
text: Union[bytes, str],
|
||||
status_code: int = ...,
|
||||
msg_prefix: str = ...,
|
||||
html: bool = ...,
|
||||
) -> None: ...
|
||||
def assertFormError(
|
||||
self,
|
||||
response: Any,
|
||||
form: Any,
|
||||
field: Any,
|
||||
errors: Any,
|
||||
response: HttpResponse,
|
||||
form: str,
|
||||
field: Optional[str],
|
||||
errors: Union[List[str], str],
|
||||
msg_prefix: str = ...,
|
||||
) -> None: ...
|
||||
def assertFormsetError(
|
||||
self,
|
||||
response: Any,
|
||||
formset: Any,
|
||||
form_index: Any,
|
||||
field: Any,
|
||||
errors: Any,
|
||||
response: HttpResponse,
|
||||
formset: str,
|
||||
form_index: Optional[int],
|
||||
field: Optional[str],
|
||||
errors: Union[List[str], str],
|
||||
msg_prefix: str = ...,
|
||||
) -> None: ...
|
||||
def assertTemplateUsed(
|
||||
self,
|
||||
response: TemplateResponse = ...,
|
||||
template_name: str = ...,
|
||||
response: Optional[Union[HttpResponse, str]] = ...,
|
||||
template_name: Optional[str] = ...,
|
||||
msg_prefix: str = ...,
|
||||
count: None = ...,
|
||||
) -> None: ...
|
||||
count: Optional[int] = ...,
|
||||
) -> Optional[_AssertTemplateUsedContext]: ...
|
||||
def assertTemplateNotUsed(
|
||||
self,
|
||||
response: Optional[Any] = ...,
|
||||
template_name: Optional[Any] = ...,
|
||||
response: Union[HttpResponse, str] = ...,
|
||||
template_name: Optional[str] = ...,
|
||||
msg_prefix: str = ...,
|
||||
): ...
|
||||
) -> Optional[_AssertTemplateNotUsedContext]: ...
|
||||
def assertRaisesMessage(
|
||||
self,
|
||||
expected_exception: Type[Exception],
|
||||
expected_message: str,
|
||||
*args: Any,
|
||||
**kwargs: Any
|
||||
) -> _GeneratorContextManager: ...
|
||||
) -> Optional[_GeneratorContextManager]: ...
|
||||
def assertWarnsMessage(
|
||||
self,
|
||||
expected_warning: Type[RuntimeWarning],
|
||||
expected_warning: Type[
|
||||
Union[
|
||||
DeprecationWarning,
|
||||
RuntimeWarning,
|
||||
UserWarning,
|
||||
ProxyModelWarning,
|
||||
RemovedInDjango30Warning,
|
||||
]
|
||||
],
|
||||
expected_message: str,
|
||||
*args: Any,
|
||||
**kwargs: Any
|
||||
) -> _GeneratorContextManager: ...
|
||||
def assertFieldOutput(
|
||||
self,
|
||||
fieldclass: Any,
|
||||
valid: Any,
|
||||
invalid: Any,
|
||||
field_args: Optional[Any] = ...,
|
||||
field_kwargs: Optional[Any] = ...,
|
||||
fieldclass: Type[EmailField],
|
||||
valid: Dict[str, str],
|
||||
invalid: Dict[str, List[str]],
|
||||
field_args: None = ...,
|
||||
field_kwargs: None = ...,
|
||||
empty_value: str = ...,
|
||||
) -> None: ...
|
||||
) -> Any: ...
|
||||
def assertHTMLEqual(
|
||||
self, html1: Any, html2: Any, msg: Optional[Any] = ...
|
||||
self, html1: str, html2: str, msg: None = ...
|
||||
) -> None: ...
|
||||
def assertHTMLNotEqual(
|
||||
self, html1: Any, html2: Any, msg: Optional[Any] = ...
|
||||
self, html1: str, html2: str, msg: None = ...
|
||||
) -> None: ...
|
||||
def assertInHTML(
|
||||
self,
|
||||
needle: Any,
|
||||
haystack: Any,
|
||||
count: Optional[Any] = ...,
|
||||
needle: str,
|
||||
haystack: SafeText,
|
||||
count: Optional[int] = ...,
|
||||
msg_prefix: str = ...,
|
||||
) -> None: ...
|
||||
def assertJSONEqual(
|
||||
self, raw: str, expected_data: str, msg: None = ...
|
||||
self,
|
||||
raw: str,
|
||||
expected_data: Union[Dict[str, str], bool, str],
|
||||
msg: None = ...,
|
||||
) -> None: ...
|
||||
def assertJSONNotEqual(
|
||||
self, raw: Any, expected_data: Any, msg: Optional[Any] = ...
|
||||
) -> None: ...
|
||||
def assertXMLEqual(
|
||||
self, xml1: Any, xml2: Any, msg: Optional[Any] = ...
|
||||
self, raw: str, expected_data: str, msg: None = ...
|
||||
) -> None: ...
|
||||
def assertXMLEqual(self, xml1: str, xml2: str, msg: None = ...) -> None: ...
|
||||
def assertXMLNotEqual(
|
||||
self, xml1: Any, xml2: Any, msg: Optional[Any] = ...
|
||||
self, xml1: str, xml2: str, msg: None = ...
|
||||
) -> None: ...
|
||||
|
||||
class TransactionTestCase(SimpleTestCase):
|
||||
@@ -186,13 +206,52 @@ class TransactionTestCase(SimpleTestCase):
|
||||
allow_database_queries: bool = ...
|
||||
def assertQuerysetEqual(
|
||||
self,
|
||||
qs: QuerySet,
|
||||
qs: Union[Iterator[Any], List[Model], QuerySet, RawQuerySet],
|
||||
values: Union[
|
||||
List[int],
|
||||
List[Union[str, None]],
|
||||
List[Optional[str]],
|
||||
List[Tuple[Model, Model]],
|
||||
List[Tuple[Model, int, int]],
|
||||
List[Tuple[str, Type[Model], int]],
|
||||
List[
|
||||
Union[
|
||||
Tuple[
|
||||
Optional[
|
||||
Union[
|
||||
bytes,
|
||||
date,
|
||||
time,
|
||||
timedelta,
|
||||
Decimal,
|
||||
Approximate,
|
||||
float,
|
||||
int,
|
||||
str,
|
||||
UUID,
|
||||
]
|
||||
],
|
||||
Optional[
|
||||
Union[
|
||||
bytes,
|
||||
date,
|
||||
time,
|
||||
timedelta,
|
||||
Decimal,
|
||||
Approximate,
|
||||
float,
|
||||
int,
|
||||
str,
|
||||
UUID,
|
||||
]
|
||||
],
|
||||
],
|
||||
int,
|
||||
]
|
||||
],
|
||||
List[date],
|
||||
Set[str],
|
||||
QuerySet,
|
||||
],
|
||||
transform: Callable = ...,
|
||||
transform: Union[Callable, Type[str]] = ...,
|
||||
ordered: bool = ...,
|
||||
msg: None = ...,
|
||||
) -> None: ...
|
||||
@@ -216,11 +275,15 @@ class TestCase(TransactionTestCase):
|
||||
class CheckCondition:
|
||||
conditions: Tuple[Tuple[Callable, str]] = ...
|
||||
def __init__(self, *conditions: Any) -> None: ...
|
||||
def add_condition(self, condition: Any, reason: Any): ...
|
||||
def __get__(self, instance: None, cls: Type[TestCase] = ...) -> bool: ...
|
||||
def add_condition(
|
||||
self, condition: Callable, reason: str
|
||||
) -> CheckCondition: ...
|
||||
def __get__(
|
||||
self, instance: None, cls: Type[TransactionTestCase] = ...
|
||||
) -> bool: ...
|
||||
|
||||
def skipIfDBFeature(*features: Any): ...
|
||||
def skipUnlessDBFeature(*features: Any): ...
|
||||
def skipIfDBFeature(*features: Any) -> Callable: ...
|
||||
def skipUnlessDBFeature(*features: Any) -> Callable: ...
|
||||
|
||||
class QuietWSGIRequestHandler(WSGIRequestHandler):
|
||||
def log_message(*args: Any) -> None: ...
|
||||
@@ -258,9 +321,9 @@ class LiveServerThread(threading.Thread):
|
||||
] = ...
|
||||
def __init__(
|
||||
self,
|
||||
host: Any,
|
||||
static_handler: Any,
|
||||
connections_override: Optional[Any] = ...,
|
||||
host: str,
|
||||
static_handler: Type[Union[StaticFilesHandler, _StaticFilesHandler]],
|
||||
connections_override: Dict[str, DatabaseWrapper] = ...,
|
||||
port: int = ...,
|
||||
) -> None: ...
|
||||
httpd: django.core.servers.basehttp.ThreadedWSGIServer = ...
|
||||
|
||||
+237
-33
@@ -1,44 +1,72 @@
|
||||
from collections import OrderedDict
|
||||
from typing import (Any, Callable, Dict, Iterator, List, Optional, Tuple, Type,
|
||||
Union)
|
||||
from contextlib import _GeneratorContextManager
|
||||
from decimal import Decimal
|
||||
from io import StringIO
|
||||
from typing import (Any, Callable, Dict, Iterator, List, Optional, Set, Tuple,
|
||||
Type, Union)
|
||||
|
||||
from django.apps.registry import Apps
|
||||
from django.conf import LazySettings
|
||||
from django.contrib.admin.tests import AdminSeleniumTestCase
|
||||
from django.contrib.admin.helpers import AdminForm
|
||||
from django.contrib.admin.views.main import ChangeList
|
||||
from django.contrib.messages.storage.fallback import FallbackStorage
|
||||
from django.db import DefaultConnectionProxy
|
||||
from django.db.backends.base.base import BaseDatabaseWrapper
|
||||
from django.db.backends.sqlite3.base import DatabaseWrapper
|
||||
from django.db.models.base import Model
|
||||
from django.forms.forms import BaseForm
|
||||
from django.forms.widgets import Media
|
||||
from django.template.base import Template
|
||||
from django.template.context import Context
|
||||
from django.test.runner import DiscoverRunner
|
||||
from django.test.testcases import (SimpleTestCase, TestCase,
|
||||
_AssertNumQueriesContext)
|
||||
from django.test.testcases import SimpleTestCase
|
||||
from django.utils.safestring import SafeText
|
||||
from django.views.generic.detail import SingleObjectTemplateResponseMixin
|
||||
|
||||
|
||||
class Approximate:
|
||||
val: Union[float, decimal.Decimal] = ...
|
||||
val: Union[decimal.Decimal, float] = ...
|
||||
places: int = ...
|
||||
def __init__(self, val: Any, places: int = ...) -> None: ...
|
||||
def __eq__(self, other: Any): ...
|
||||
def __init__(
|
||||
self, val: Union[Decimal, float], places: int = ...
|
||||
) -> None: ...
|
||||
def __eq__(self, other: Union[Decimal, float]) -> bool: ...
|
||||
|
||||
class ContextList(list):
|
||||
def __getitem__(self, key: Union[str, int]) -> Any: ...
|
||||
def get(self, key: Any, default: Optional[Any] = ...): ...
|
||||
def __getitem__(
|
||||
self, key: Union[int, str]
|
||||
) -> Optional[
|
||||
Union[
|
||||
List[Union[List[str], str]],
|
||||
bool,
|
||||
AdminForm,
|
||||
ChangeList,
|
||||
FallbackStorage,
|
||||
Model,
|
||||
BaseForm,
|
||||
Media,
|
||||
Context,
|
||||
SingleObjectTemplateResponseMixin,
|
||||
str,
|
||||
]
|
||||
]: ...
|
||||
def get(self, key: str, default: Optional[str] = ...) -> str: ...
|
||||
def __contains__(self, key: str) -> bool: ...
|
||||
def keys(self): ...
|
||||
def keys(self) -> Set[str]: ...
|
||||
|
||||
class _TestState: ...
|
||||
|
||||
def setup_test_environment(debug: bool = ...) -> None: ...
|
||||
def setup_test_environment(debug: Optional[bool] = ...) -> None: ...
|
||||
def teardown_test_environment() -> None: ...
|
||||
def get_runner(
|
||||
settings: LazySettings, test_runner_class: None = ...
|
||||
) -> Type[DiscoverRunner]: ...
|
||||
settings: LazySettings, test_runner_class: Optional[str] = ...
|
||||
) -> Type[Union[Any, DiscoverRunner]]: ...
|
||||
|
||||
class TestContextDecorator:
|
||||
attr_name: Any = ...
|
||||
kwarg_name: Any = ...
|
||||
def __init__(
|
||||
self, attr_name: Optional[str] = ..., kwarg_name: None = ...
|
||||
self, attr_name: Optional[str] = ..., kwarg_name: Optional[str] = ...
|
||||
) -> None: ...
|
||||
def enable(self) -> None: ...
|
||||
def disable(self) -> None: ...
|
||||
@@ -51,32 +79,203 @@ class TestContextDecorator:
|
||||
) -> Type[SimpleTestCase]: ...
|
||||
def decorate_callable(self, func: Callable) -> Callable: ...
|
||||
def __call__(
|
||||
self, decorated: Union[Type[SimpleTestCase], Callable]
|
||||
) -> Union[Type[SimpleTestCase], Callable]: ...
|
||||
self,
|
||||
decorated: Union[
|
||||
Callable, Type[Union[SimpleTestCase, LoggingCaptureMixin]]
|
||||
],
|
||||
) -> Union[Callable, Type[Union[SimpleTestCase, LoggingCaptureMixin]]]: ...
|
||||
|
||||
class override_settings(TestContextDecorator):
|
||||
attr_name: None
|
||||
kwarg_name: None
|
||||
options: Dict[str, Any] = ...
|
||||
options: Union[
|
||||
Dict[str, Dict[str, Callable]],
|
||||
Dict[
|
||||
str,
|
||||
Dict[
|
||||
str,
|
||||
Union[
|
||||
Dict[str, Optional[str]],
|
||||
Dict[str, Union[Callable, Dict[str, int], str]],
|
||||
Dict[str, Union[Dict[str, int], int, str]],
|
||||
],
|
||||
],
|
||||
],
|
||||
Dict[
|
||||
str,
|
||||
List[
|
||||
Dict[
|
||||
str, Union[Dict[str, List[Tuple[str, Dict[str, str]]]], str]
|
||||
]
|
||||
],
|
||||
],
|
||||
Dict[
|
||||
str,
|
||||
List[
|
||||
Union[
|
||||
Dict[str, Union[Dict[Any, Any], bool, str]],
|
||||
Dict[str, Union[Dict[str, bool], bool, str]],
|
||||
]
|
||||
],
|
||||
],
|
||||
Dict[
|
||||
str,
|
||||
List[
|
||||
Union[
|
||||
Dict[str, Union[Dict[str, List[str]], str]],
|
||||
Dict[str, Union[bool, str]],
|
||||
]
|
||||
],
|
||||
],
|
||||
Dict[
|
||||
str,
|
||||
List[
|
||||
Union[
|
||||
Dict[str, Union[Dict[str, bool], str]],
|
||||
Dict[str, Union[Dict[str, int], str]],
|
||||
]
|
||||
],
|
||||
],
|
||||
Dict[
|
||||
str,
|
||||
List[
|
||||
Union[
|
||||
Dict[str, Union[Dict[str, int], str]],
|
||||
Dict[str, Union[Dict[str, str], str]],
|
||||
]
|
||||
],
|
||||
],
|
||||
Dict[str, List[unittest.mock.Mock]],
|
||||
Dict[str, Optional[Union[List[str], bool]]],
|
||||
Dict[str, Optional[Union[bool, str]]],
|
||||
Dict[str, Tuple[Tuple[str, str], Tuple[str, str]]],
|
||||
Dict[str, Type[Any]],
|
||||
Dict[str, Union[Callable, bool]],
|
||||
Dict[str, Union[Dict[int, None], bool]],
|
||||
Dict[str, Union[Dict[str, None], List[str]]],
|
||||
Dict[str, Union[Dict[str, Optional[str]], str]],
|
||||
Dict[
|
||||
str,
|
||||
Union[
|
||||
Dict[
|
||||
str,
|
||||
Union[
|
||||
Dict[Any, Any],
|
||||
Dict[str, Callable],
|
||||
Dict[str, int],
|
||||
Dict[str, str],
|
||||
],
|
||||
],
|
||||
List[
|
||||
Dict[str, Union[Dict[str, List[str]], List[str], bool, str]]
|
||||
],
|
||||
List[Union[Tuple[str, str], str]],
|
||||
int,
|
||||
str,
|
||||
],
|
||||
],
|
||||
Dict[
|
||||
str,
|
||||
Union[
|
||||
Dict[
|
||||
str,
|
||||
Union[
|
||||
Dict[str, Dict[str, Union[List[str], bool, str]]],
|
||||
Dict[str, Dict[str, str]],
|
||||
int,
|
||||
],
|
||||
],
|
||||
str,
|
||||
],
|
||||
],
|
||||
Dict[
|
||||
str,
|
||||
Union[
|
||||
Dict[
|
||||
str,
|
||||
Union[
|
||||
Dict[
|
||||
str,
|
||||
Union[
|
||||
Callable,
|
||||
Dict[str, Union[Dict[str, bool], bool]],
|
||||
],
|
||||
],
|
||||
Dict[
|
||||
str,
|
||||
Union[Dict[str, Union[Dict[str, bool], bool]], int],
|
||||
],
|
||||
Dict[
|
||||
str,
|
||||
Union[Dict[str, Union[Dict[str, bool], bool]], str],
|
||||
],
|
||||
str,
|
||||
],
|
||||
],
|
||||
List[str],
|
||||
],
|
||||
],
|
||||
Dict[
|
||||
str,
|
||||
Union[
|
||||
Dict[
|
||||
str,
|
||||
Union[
|
||||
Dict[str, Union[Callable, str]],
|
||||
Dict[str, Union[Dict[str, int], str]],
|
||||
Dict[str, Union[int, str]],
|
||||
Dict[str, str],
|
||||
],
|
||||
],
|
||||
bool,
|
||||
],
|
||||
],
|
||||
Dict[str, Union[Dict[str, Union[Dict[str, str], str]], bool]],
|
||||
Dict[
|
||||
str,
|
||||
Union[
|
||||
List[
|
||||
Dict[str, Union[Dict[str, List[Any]], List[Any], bool, str]]
|
||||
],
|
||||
List[str],
|
||||
],
|
||||
],
|
||||
Dict[
|
||||
str,
|
||||
Union[
|
||||
List[Dict[str, Union[Dict[str, Tuple[str]], List[str], str]]],
|
||||
List[str],
|
||||
int,
|
||||
str,
|
||||
],
|
||||
],
|
||||
Dict[str, Union[List[Dict[str, Union[List[Any], bool, str]]], int]],
|
||||
Dict[str, Union[List[int], List[str], str]],
|
||||
Dict[str, Union[Tuple[str], str]],
|
||||
Dict[str, Union[float, str]],
|
||||
Dict[str, bytes],
|
||||
] = ...
|
||||
def __init__(self, **kwargs: Any) -> None: ...
|
||||
wrapped: Union[django.conf.Settings, django.conf.UserSettingsHolder] = ...
|
||||
def enable(self) -> None: ...
|
||||
def disable(self) -> None: ...
|
||||
def save_options(self, test_func: Type[SimpleTestCase]) -> None: ...
|
||||
def save_options(
|
||||
self, test_func: Type[Union[SimpleTestCase, LoggingCaptureMixin]]
|
||||
) -> None: ...
|
||||
def decorate_class(
|
||||
self, cls: Type[SimpleTestCase]
|
||||
) -> Type[SimpleTestCase]: ...
|
||||
self, cls: Type[Union[SimpleTestCase, LoggingCaptureMixin]]
|
||||
) -> Type[Union[SimpleTestCase, LoggingCaptureMixin]]: ...
|
||||
|
||||
class modify_settings(override_settings):
|
||||
attr_name: None
|
||||
kwarg_name: None
|
||||
wrapped: Union[django.conf.Settings, django.conf.UserSettingsHolder]
|
||||
operations: List[Tuple[str, Dict[str, Union[List[str], str]]]] = ...
|
||||
operations: List[
|
||||
Union[Tuple[str, Dict[str, List[str]]], Tuple[str, Dict[str, str]]]
|
||||
] = ...
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
def save_options(
|
||||
self, test_func: Type[Union[TestCase, AdminSeleniumTestCase]]
|
||||
) -> None: ...
|
||||
options: Dict[str, List[Union[str, Tuple[str, str]]]] = ...
|
||||
def save_options(self, test_func: Type[SimpleTestCase]) -> None: ...
|
||||
options: Dict[str, List[Union[Tuple[str, str], str]]] = ...
|
||||
def enable(self) -> None: ...
|
||||
|
||||
class override_system_checks(TestContextDecorator):
|
||||
@@ -86,7 +285,9 @@ class override_system_checks(TestContextDecorator):
|
||||
new_checks: List[Callable] = ...
|
||||
deployment_checks: Optional[List[Callable]] = ...
|
||||
def __init__(
|
||||
self, new_checks: Any, deployment_checks: Optional[Any] = ...
|
||||
self,
|
||||
new_checks: List[Callable],
|
||||
deployment_checks: Optional[List[Callable]] = ...,
|
||||
) -> None: ...
|
||||
old_checks: Set[Callable] = ...
|
||||
old_deployment_checks: Set[Callable] = ...
|
||||
@@ -95,16 +296,18 @@ class override_system_checks(TestContextDecorator):
|
||||
|
||||
class CaptureQueriesContext:
|
||||
connection: django.db.DefaultConnectionProxy = ...
|
||||
def __init__(self, connection: DatabaseWrapper) -> None: ...
|
||||
def __init__(
|
||||
self, connection: Union[DefaultConnectionProxy, DatabaseWrapper]
|
||||
) -> None: ...
|
||||
def __iter__(self): ...
|
||||
def __getitem__(self, index: Any): ...
|
||||
def __getitem__(self, index: int) -> Dict[str, str]: ...
|
||||
def __len__(self) -> int: ...
|
||||
@property
|
||||
def captured_queries(self) -> List[Dict[str, str]]: ...
|
||||
force_debug_cursor: bool = ...
|
||||
initial_queries: int = ...
|
||||
final_queries: Optional[int] = ...
|
||||
def __enter__(self) -> _AssertNumQueriesContext: ...
|
||||
def __enter__(self) -> CaptureQueriesContext: ...
|
||||
def __exit__(
|
||||
self, exc_type: None, exc_value: None, traceback: None
|
||||
) -> None: ...
|
||||
@@ -112,8 +315,9 @@ class CaptureQueriesContext:
|
||||
class ignore_warnings(TestContextDecorator):
|
||||
attr_name: None
|
||||
kwarg_name: None
|
||||
ignore_kwargs: Dict[
|
||||
str, Union[Type[django.utils.deprecation.RemovedInDjango30Warning], str]
|
||||
ignore_kwargs: Union[
|
||||
Dict[str, Type[django.utils.deprecation.RemovedInDjango30Warning]],
|
||||
Dict[str, str],
|
||||
] = ...
|
||||
filter_func: Callable = ...
|
||||
def __init__(self, **kwargs: Any) -> None: ...
|
||||
@@ -123,7 +327,7 @@ class ignore_warnings(TestContextDecorator):
|
||||
|
||||
requires_tz_support: Any
|
||||
|
||||
def isolate_lru_cache(lru_cache_object: Any) -> None: ...
|
||||
def isolate_lru_cache(lru_cache_object: Callable) -> Iterator[None]: ...
|
||||
|
||||
class override_script_prefix(TestContextDecorator):
|
||||
attr_name: None
|
||||
|
||||
Reference in new issue
Block a user