better stubs

This commit is contained in:
Maxim Kurnikov committed 2018-08-05 03:13:19 +03:00
1 parent 4013fe4d03
commit fa718b8e55
380 files changed
+11805 -8503

No files matched your search

+156 -150
View File
@@ -1,150 +1,101 @@
from django.contrib.auth.base_user import AbstractBaseUser
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.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.response import (
FileResponse,
HttpResponse,
HttpResponseBase,
HttpResponseForbidden,
HttpResponseRedirect,
)
from django.http.response import (HttpResponse, HttpResponseBase,
HttpResponseRedirect)
from django.template.base import Template
from django.template.context import Context
from django.test.utils import ContextList
from typing import Any, Callable, Dict, List, Optional, Union
from urllib.parse import ParseResult
def closing_iterator_wrapper(iterable: map, close: Callable) -> None: ...
def conditional_content_removal(
request: HttpRequest, response: HttpResponseBase
) -> HttpResponseBase: ...
def encode_file(boundary: str, key: str, file: object) -> List[bytes]: ...
def encode_multipart(boundary: str, data: Dict[str, Any]) -> bytes: ...
def store_rendered_templates(
store: Dict[str, Union[List[Template], ContextList]],
signal: Signal,
sender: Template,
template: Template,
context: Context,
**kwargs,
) -> None: ...
class Client:
def __init__(self, enforce_csrf_checks: bool = ..., **defaults) -> None: ...
def _handle_redirects(
self,
response: Union[HttpResponseForbidden, HttpResponseRedirect],
data: Any = ...,
content_type: str = ...,
**extra,
) -> HttpResponse: ...
def _login(self, user: AbstractBaseUser, backend: Optional[str] = ...) -> None: ...
def _parse_json(
self, response: HttpResponse, **extra
) -> Dict[str, Union[int, str]]: ...
def delete(
self,
path: str,
data: Union[str, Dict[str, str]] = ...,
content_type: str = ...,
follow: bool = ...,
secure: bool = ...,
**extra,
) -> HttpResponse: ...
def force_login(self, user: User, backend: Optional[str] = ...) -> None: ...
def get(
self,
path: str,
data: Optional[Union[Dict[str, str], QueryDict]] = ...,
follow: bool = ...,
secure: bool = ...,
**extra,
) -> HttpResponseBase: ...
def head(
self,
path: str,
data: Optional[Dict[str, str]] = ...,
follow: bool = ...,
secure: bool = ...,
**extra,
) -> HttpResponse: ...
def login(self, **credentials) -> bool: ...
def logout(self) -> None: ...
def options(
self,
path: str,
data: Union[str, Dict[str, str]] = ...,
content_type: str = ...,
follow: bool = ...,
secure: bool = ...,
**extra,
) -> HttpResponse: ...
def patch(
self,
path: str,
data: Union[str, Dict[str, str]] = ...,
content_type: str = ...,
follow: bool = ...,
secure: bool = ...,
**extra,
) -> HttpResponse: ...
def post(
self,
path: str,
data: Any = ...,
content_type: str = ...,
follow: bool = ...,
secure: bool = ...,
**extra,
) -> HttpResponse: ...
def put(
self,
path: str,
data: Union[str, bytes] = ...,
content_type: str = ...,
follow: bool = ...,
secure: bool = ...,
**extra,
) -> HttpResponse: ...
def request(self, **request): ...
@property
def session(self) -> SessionBase: ...
def store_exc_info(self, **kwargs) -> None: ...
def trace(
self,
path: str,
data: Dict[str, str] = ...,
follow: bool = ...,
secure: bool = ...,
**extra,
) -> HttpResponse: ...
class ClientHandler:
def __call__(self, environ: Dict[str, Any]) -> HttpResponseBase: ...
def __init__(self, enforce_csrf_checks: bool = ..., *args, **kwargs) -> None: ...
class RedirectCycleError(Exception):
last_response: django.http.response.HttpResponseRedirect = ...
redirect_chain: List[Tuple[str, int]] = ...
def __init__(
self, message: str, last_response: HttpResponseRedirect
) -> None: ...
class FakePayload:
read_started: bool = ...
def __init__(self, content: Optional[Union[str, bytes]] = ...) -> None: ...
def __len__(self) -> int: ...
def read(self, num_bytes: int = ...) -> bytes: ...
def write(self, content: Union[str, bytes]) -> 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 encode_multipart(boundary: str, data: Dict[str, Any]) -> bytes: ...
def encode_file(boundary: str, key: str, file: Any) -> List[bytes]: ...
class RequestFactory:
def __init__(self, *, json_encoder=..., **defaults) -> None: ...
def _base_environ(self, **request) -> Dict[str, Any]: ...
def _encode_data(self, data: Any, content_type: str) -> bytes: ...
def _encode_json(self, data: Any, content_type: str) -> Any: ...
def _get_path(self, parsed: ParseResult) -> str: ...
json_encoder: Type[django.core.serializers.json.DjangoJSONEncoder] = ...
defaults: Dict[str, str] = ...
cookies: http.cookies.SimpleCookie = ...
errors: _io.BytesIO = ...
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
) -> Union[WSGIRequest, HttpResponseBase]: ...
def post(
self,
path: str,
data: Any = ...,
content_type: str = ...,
secure: bool = ...,
**extra: Any
) -> Union[WSGIRequest, HttpResponseBase]: ...
def head(
self,
path: str,
data: Optional[Union[str, Dict[str, str]]] = ...,
secure: bool = ...,
**extra: Any
) -> Union[WSGIRequest, HttpResponse]: ...
def trace(
self, path: str, secure: bool = ..., **extra: Any
) -> Union[WSGIRequest, HttpResponse]: ...
def options(
self,
path: str,
data: Union[str, Dict[str, str]] = ...,
content_type: str = ...,
secure: bool = ...,
**extra: Any
) -> Union[WSGIRequest, HttpResponse]: ...
def put(
self,
path: str,
data: Union[str, bytes, Dict[str, str], Dict[str, int]] = ...,
content_type: str = ...,
secure: bool = ...,
**extra: Any
) -> Union[WSGIRequest, HttpResponse]: ...
def patch(
self,
path: str,
data: Union[str, Dict[str, str], Dict[str, int]] = ...,
content_type: str = ...,
secure: bool = ...,
**extra: Any
) -> Union[WSGIRequest, HttpResponse]: ...
def delete(
self,
path: str,
data: Union[str, Dict[str, int]] = ...,
data: Union[str, Dict[str, str], Dict[str, int]] = ...,
content_type: str = ...,
secure: bool = ...,
**extra,
**extra: Any
) -> Union[WSGIRequest, HttpResponse]: ...
def generic(
self,
@@ -153,47 +104,102 @@ class RequestFactory:
data: Union[str, bytes, Dict[str, str]] = ...,
content_type: Optional[str] = ...,
secure: bool = ...,
**extra,
**extra: Any
) -> Union[WSGIRequest, HttpResponseBase]: ...
class Client(RequestFactory):
defaults: Dict[str, str]
errors: _io.BytesIO
json_encoder: Union[
unittest.mock.MagicMock,
Type[django.core.serializers.json.DjangoJSONEncoder],
]
handler: django.test.client.ClientHandler = ...
exc_info: None = ...
def __init__(
self, enforce_csrf_checks: bool = ..., **defaults: Any
) -> None: ...
def store_exc_info(self, **kwargs: Any) -> None: ...
@property
def session(self) -> SessionBase: ...
def request(self, **request: Any) -> Any: ...
def get(
self, path: str, data: Any = ..., secure: bool = ..., **extra
) -> Union[WSGIRequest, HttpResponse, FileResponse]: ...
def head(
self, path: str, data: Optional[Dict[str, str]] = ..., secure: bool = ..., **extra
) -> Union[WSGIRequest, HttpResponse]: ...
def options(
self,
path: str,
data: Dict[str, str] = ...,
content_type: str = ...,
data: Optional[
Union[
Dict[str, Union[str, int]],
QueryDict,
str,
Dict[str, Union[str, Tuple[str, str, str]]],
]
] = ...,
follow: bool = ...,
secure: bool = ...,
**extra,
) -> HttpResponseRedirect: ...
def patch(
self,
path: str,
data: str = ...,
content_type: str = ...,
secure: bool = ...,
**extra,
) -> HttpResponse: ...
**extra: Any
) -> HttpResponseBase: ...
def post(
self,
path: str,
data: Any = ...,
content_type: str = ...,
follow: bool = ...,
secure: bool = ...,
**extra,
) -> Union[WSGIRequest, HttpResponseBase]: ...
def put(
**extra: Any
) -> HttpResponseBase: ...
def head(
self,
path: str,
data: Optional[Union[str, Dict[str, str]]] = ...,
follow: bool = ...,
secure: bool = ...,
**extra: Any
) -> HttpResponse: ...
def options(
self,
path: str,
data: Union[str, Dict[str, str]] = ...,
content_type: str = ...,
follow: bool = ...,
secure: bool = ...,
**extra,
**extra: Any
) -> HttpResponse: ...
def put(
self,
path: str,
data: Union[str, bytes, Dict[str, str], Dict[str, int]] = ...,
content_type: str = ...,
follow: bool = ...,
secure: bool = ...,
**extra: Any
) -> HttpResponse: ...
def patch(
self,
path: str,
data: Union[str, Dict[str, str], Dict[str, int]] = ...,
content_type: str = ...,
follow: bool = ...,
secure: bool = ...,
**extra: Any
) -> HttpResponse: ...
def delete(
self,
path: str,
data: Union[str, Dict[str, str], Dict[str, int]] = ...,
content_type: str = ...,
follow: bool = ...,
secure: bool = ...,
**extra: Any
) -> HttpResponse: ...
def request(self, **request) -> WSGIRequest: ...
def trace(
self, path: str, secure: bool = ..., **extra
) -> Union[WSGIRequest, HttpResponse]: ...
self,
path: str,
data: Union[str, Dict[str, str]] = ...,
follow: bool = ...,
secure: bool = ...,
**extra: Any
) -> HttpResponse: ...
def login(self, **credentials: Any) -> bool: ...
def force_login(self, user: User, backend: Optional[str] = ...) -> None: ...
cookies: http.cookies.SimpleCookie = ...
def logout(self) -> None: ...
+18 -30
View File
@@ -1,44 +1,32 @@
# Stubs for django.test.html (Python 3.6)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
from html.parser import HTMLParser
from typing import Any, Optional
from typing import List, Optional, Tuple, Union
from typing import Any, List, Optional, Tuple, Union
WHITESPACE: Any
def normalize_whitespace(string: str) -> str: ...
class Element:
name: Any = ...
attributes: Any = ...
children: Any = ...
name: str = ...
attributes: List[Tuple[str, Optional[str]]] = ...
children: List[Union[django.test.html.Element, str]] = ...
def __init__(
self,
name: Optional[str],
attributes: Union[
Tuple,
List[Union[Tuple[str, str], Tuple[str, None]]],
List[Tuple[str, None]],
List[Tuple[str, str]],
],
attributes: Union[List[Tuple[str, Union[str, None]]], Tuple],
) -> None: ...
def append(self, element: Union[str, Element]) -> None: ...
def finalize(self) -> None: ...
def __eq__(self, element: Union[str, Element]) -> bool: ...
def __eq__(self, element: Element) -> bool: ...
def __hash__(self) -> int: ...
def _count(self, element: Union[str, Element], count: bool = ...) -> int: ...
def __contains__(self, element: Element) -> bool: ...
def count(self, element: Element) -> 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 __str__(self) -> str: ...
def __repr__(self) -> str: ...
class RootElement(Element):
attributes: List[Any]
children: List[Union[django.test.html.Element, str]]
name: None
def __init__(self) -> None: ...
def __str__(self) -> str: ...
class HTMLParseError(Exception): ...
@@ -48,17 +36,17 @@ class Parser(HTMLParser):
open_tags: Any = ...
element_positions: Any = ...
def __init__(self) -> None: ...
def error(self, msg: Any) -> None: ...
def error(self, msg: str) -> Any: ...
def format_position(
self, position: Optional[Any] = ..., element: Optional[Any] = ...
): ...
self, position: None = ..., element: None = ...
) -> str: ...
@property
def current(self) -> Element: ...
def handle_startendtag(self, tag: str, attrs: List[Tuple[str, str]]) -> None: ...
def handle_startendtag(
self, tag: str, attrs: List[Tuple[str, Optional[str]]]
) -> None: ...
def handle_starttag(
self,
tag: str,
attrs: Union[List[Union[Tuple[str, str], Tuple[str, None]]], List[Tuple[str, str]]],
self, tag: str, attrs: List[Tuple[str, Optional[str]]]
) -> None: ...
def handle_endtag(self, tag: str) -> None: ...
def handle_data(self, data: str) -> None: ...
+66 -60
View File
@@ -1,47 +1,55 @@
# Stubs for django.test.runner (Python 3.6)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
import unittest
from typing import Any, Optional
from django.db.backends.dummy.base import DatabaseWrapper
from django.db.backends.sqlite3.base import DatabaseWrapper
from django.test.testcases import SimpleTestCase, TestCase
from django.utils.datastructures import OrderedSet
from argparse import ArgumentParser
from typing import Any, Dict, List, Optional, Set, Tuple, Type, Union
from unittest.case import _SubTest
from unittest.runner import TextTestResult
from unittest.case import TestCase, _SubTest
from unittest.runner import TextTestResult, _WritelnDecorator
from unittest.suite import TestSuite
from django.db.backends.base.base import BaseDatabaseWrapper
from django.test.testcases import SimpleTestCase, TestCase
from django.utils.datastructures import OrderedSet
class DebugSQLTextTestResult(unittest.TextTestResult):
logger: Any = ...
def __init__(self, stream: Any, descriptions: Any, verbosity: Any) -> None: ...
debug_sql_stream: Any = ...
handler: Any = ...
buffer: bool
descriptions: bool
dots: bool
errors: List[Tuple[unittest.case.TestCase, str, str]]
expectedFailures: List[Any]
failfast: bool
failures: List[Tuple[unittest.case.TestCase, str, str]]
shouldStop: bool
showAll: bool
skipped: List[Any]
stream: unittest.runner._WritelnDecorator
tb_locals: bool
testsRun: int
unexpectedSuccesses: List[Any]
logger: logging.Logger = ...
def __init__(
self, stream: _WritelnDecorator, descriptions: bool, verbosity: int
) -> None: ...
debug_sql_stream: _io.StringIO = ...
handler: logging.StreamHandler = ...
def startTest(self, test: TestCase) -> None: ...
def stopTest(self, test: TestCase) -> None: ...
def addError(self, test: Any, err: Any) -> None: ...
def addFailure(self, test: Any, err: Any) -> None: ...
def addSubTest(self, test: TestCase, subtest: _SubTest, err: None) -> None: ...
def addSubTest(
self, test: TestCase, subtest: _SubTest, err: None
) -> None: ...
def printErrorList(
self,
flavour: str,
errors: List[Union[Tuple[TestCase, str, str], Tuple[_SubTest, str, str]]],
self, flavour: str, errors: List[Tuple[TestCase, str, str]]
) -> None: ...
class RemoteTestResult:
events: Any = ...
events: List[Any] = ...
failfast: bool = ...
shouldStop: bool = ...
testsRun: int = ...
def __init__(self) -> None: ...
@property
def test_index(self): ...
def _confirm_picklable(self, obj: Any) -> None: ...
def _print_unpicklable_subtest(
self, test: Any, subtest: Any, pickle_exc: Any
) -> None: ...
def check_picklable(self, test: Any, err: Any) -> None: ...
def check_subtest_picklable(self, test: Any, subtest: Any) -> None: ...
def stop_if_failfast(self) -> None: ...
@@ -61,16 +69,13 @@ class RemoteTestResult:
class RemoteTestRunner:
resultclass: Any = ...
failfast: Any = ...
def __init__(self, failfast: bool = ..., resultclass: Optional[Any] = ...) -> None: ...
def __init__(
self, failfast: bool = ..., resultclass: Optional[Any] = ...
) -> None: ...
def run(self, test: Any): ...
def default_test_processes() -> int: ...
_worker_id: int
def _init_worker(counter: Any) -> None: ...
def _run_subsuite(args: Any): ...
class ParallelTestSuite(unittest.TestSuite):
init_worker: Any = ...
run_subsuite: Any = ...
@@ -78,7 +83,9 @@ class ParallelTestSuite(unittest.TestSuite):
subsuites: Any = ...
processes: Any = ...
failfast: Any = ...
def __init__(self, suite: Any, processes: Any, failfast: bool = ...) -> None: ...
def __init__(
self, suite: Any, processes: Any, failfast: bool = ...
) -> None: ...
def run(self, result: Any): ...
class DiscoverRunner:
@@ -87,21 +94,21 @@ class DiscoverRunner:
test_runner: Any = ...
test_loader: Any = ...
reorder_by: Any = ...
pattern: Any = ...
top_level: Any = ...
verbosity: Any = ...
interactive: Any = ...
failfast: Any = ...
keepdb: Any = ...
reverse: Any = ...
debug_mode: Any = ...
debug_sql: Any = ...
parallel: Any = ...
tags: Any = ...
exclude_tags: Any = ...
pattern: Optional[str] = ...
top_level: None = ...
verbosity: int = ...
interactive: bool = ...
failfast: bool = ...
keepdb: bool = ...
reverse: bool = ...
debug_mode: bool = ...
debug_sql: bool = ...
parallel: int = ...
tags: Set[str] = ...
exclude_tags: Set[str] = ...
def __init__(
self,
pattern: None = ...,
pattern: Optional[str] = ...,
top_level: None = ...,
verbosity: int = ...,
interactive: bool = ...,
@@ -112,40 +119,39 @@ class DiscoverRunner:
debug_sql: bool = ...,
parallel: int = ...,
tags: Optional[List[str]] = ...,
exclude_tags: None = ...,
**kwargs: Any,
exclude_tags: Optional[List[str]] = ...,
**kwargs: Any
) -> None: ...
@classmethod
def add_arguments(cls, parser: Any) -> None: ...
def add_arguments(cls, parser: ArgumentParser) -> None: ...
def setup_test_environment(self, **kwargs: Any) -> None: ...
def build_suite(
self,
test_labels: Union[Tuple[str, str], List[str], Tuple[str]] = ...,
extra_tests: None = ...,
**kwargs: Any,
test_labels: Union[Tuple[str, str], List[str]] = ...,
extra_tests: Optional[List[Any]] = ...,
**kwargs: Any
) -> TestSuite: ...
def setup_databases(
self, **kwargs: Any
) -> Union[
List[Tuple[DatabaseWrapper, str, bool]], List[Tuple[DatabaseWrapper, str, bool]]
]: ...
def get_resultclass(self) -> None: ...
) -> List[Tuple[BaseDatabaseWrapper, str, bool]]: ...
def get_resultclass(self) -> Optional[Type[DebugSQLTextTestResult]]: ...
def get_test_runner_kwargs(self) -> Dict[str, Optional[int]]: ...
def run_checks(self) -> None: ...
def run_suite(self, suite: TestSuite, **kwargs: Any) -> TextTestResult: ...
def teardown_databases(
self,
old_config: Union[
List[Tuple[DatabaseWrapper, str, bool]], List[Tuple[DatabaseWrapper, str, bool]]
],
**kwargs: Any,
old_config: List[Tuple[BaseDatabaseWrapper, str, bool]],
**kwargs: Any
) -> None: ...
def teardown_test_environment(self, **kwargs: Any) -> None: ...
def suite_result(
self, suite: TestSuite, result: TextTestResult, **kwargs: Any
) -> int: ...
def run_tests(
self, test_labels: List[str], extra_tests: List[Any] = ..., **kwargs: Any
self,
test_labels: List[str],
extra_tests: List[Any] = ...,
**kwargs: Any
) -> int: ...
def is_discoverable(label: str) -> bool: ...
+3 -14
View File
@@ -1,13 +1,7 @@
# Stubs for django.test.selenium (Python 3.6)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
from django.test import LiveServerTestCase
from typing import Any
from django.contrib.admin.tests import AdminSeleniumTestCase
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from typing import Callable, Dict, List, Tuple, Type, Union
class SeleniumTestCaseBase:
browsers: Any = ...
@@ -15,12 +9,9 @@ class SeleniumTestCaseBase:
def __new__(
cls: Type[SeleniumTestCaseBase],
name: str,
bases: Union[
Tuple[Type[AdminSeleniumTestCase]],
Tuple[Type[SeleniumTestCase], Type[StaticLiveServerTestCase]],
],
bases: Tuple[Type[SeleniumTestCase]],
attrs: Dict[str, Union[str, List[str], Callable]],
) -> Type[AdminSeleniumTestCase]: ...
) -> Type[SeleniumTestCase]: ...
@classmethod
def import_webdriver(cls, browser: Any): ...
def create_webdriver(self): ...
@@ -29,6 +20,4 @@ class SeleniumTestCase(LiveServerTestCase):
implicit_wait: int = ...
@classmethod
def setUpClass(cls) -> None: ...
@classmethod
def _tearDownClassInternal(cls) -> None: ...
def disable_implicit_wait(self) -> None: ...
+1 -5
View File
@@ -1,8 +1,4 @@
# Stubs for django.test.signals (Python 3.6)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
from typing import Any
from typing import Any, Optional
template_rendered: Any
COMPLEX_OVERRIDE_SETTINGS: Any
+111 -124
View File
@@ -1,36 +1,46 @@
# Stubs for django.test.testcases (Python 3.6)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
import threading
import unittest
from django.core.handlers.wsgi import WSGIHandler
from django.core.servers.basehttp import WSGIRequestHandler
from django.test.utils import CaptureQueriesContext
from typing import Any, Optional
from contextlib import _GeneratorContextManager
from django.db.backends.sqlite3.base import DatabaseWrapper
from django.http.response import HttpResponse, HttpResponseBase
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Type, Union
from unittest.case import _AssertRaisesContext, _AssertWarnsContext
from typing import Any, Callable, List, Optional, Tuple, Type, Union
from unittest.runner import TextTestResult
from django.core.handlers.wsgi import WSGIHandler
from django.core.servers.basehttp import WSGIRequestHandler
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.test.html import Element
from django.test.utils import CaptureQueriesContext, override_settings
class _AssertNumQueriesContext(CaptureQueriesContext):
test_case: Any = ...
num: Any = ...
connection: django.db.backends.sqlite3.base.DatabaseWrapper
final_queries: Optional[int]
force_debug_cursor: bool
initial_queries: int
test_case: Union[
django.test.testcases.TransactionTestCase,
django.test.testcases.SerializeMixin,
] = ...
num: int = ...
def __init__(self, test_case: Any, num: Any, connection: Any) -> None: ...
def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any): ...
class _AssertTemplateUsedContext:
test_case: Any = ...
template_name: Any = ...
rendered_templates: Any = ...
rendered_template_names: Any = ...
context: Any = ...
test_case: django.test.testcases.SimpleTestCase = ...
template_name: str = ...
rendered_templates: List[django.template.base.Template] = ...
rendered_template_names: List[str] = ...
context: django.test.utils.ContextList = ...
def __init__(self, test_case: Any, template_name: Any) -> None: ...
def on_template_render(
self, sender: Any, signal: Any, template: Any, context: Any, **kwargs: Any
self,
sender: Any,
signal: Any,
template: Any,
context: Any,
**kwargs: Any
) -> None: ...
def test(self): ...
def message(self): ...
@@ -38,66 +48,63 @@ class _AssertTemplateUsedContext:
def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any): ...
class _AssertTemplateNotUsedContext(_AssertTemplateUsedContext):
context: django.test.utils.ContextList
rendered_template_names: List[str]
rendered_templates: List[django.template.base.Template]
template_name: str
test_case: django.test.testcases.SimpleTestCase
def test(self): ...
def message(self): ...
class _CursorFailure:
cls_name: Any = ...
wrapped: Any = ...
cls_name: str = ...
wrapped: Callable = ...
def __init__(self, cls_name: Any, wrapped: Any) -> None: ...
def __call__(self) -> None: ...
class SimpleTestCase(unittest.TestCase):
client_class: Any = ...
_overridden_settings: Any = ...
_modified_settings: Any = ...
allow_database_queries: bool = ...
@classmethod
def setUpClass(cls) -> None: ...
@classmethod
def tearDownClass(cls) -> None: ...
def __call__(self, result: TextTestResult = ...) -> None: ...
client: Any = ...
def _pre_setup(self) -> None: ...
def _post_teardown(self) -> None: ...
def settings(self, **kwargs: Any): ...
def settings(self, **kwargs: Any) -> override_settings: ...
def modify_settings(self, **kwargs: Any): ...
def assertRedirects(
self,
response: Any,
expected_url: Any,
response: HttpResponse,
expected_url: str,
status_code: int = ...,
target_status_code: int = ...,
msg_prefix: str = ...,
fetch_redirect_response: bool = ...,
) -> None: ...
def _assert_contains(
self,
response: HttpResponseBase,
text: Union[str, bytes, int],
status_code: int,
msg_prefix: str,
html: bool,
) -> Tuple[str, int, str]: ...
def assertContains(
self,
response: Any,
text: Any,
count: Optional[Any] = ...,
response: HttpResponse,
text: Union[str, bytes],
count: None = ...,
status_code: int = ...,
msg_prefix: str = ...,
html: bool = ...,
) -> None: ...
def assertNotContains(
self,
response: Any,
text: Any,
response: TemplateResponse,
text: str,
status_code: int = ...,
msg_prefix: str = ...,
html: bool = ...,
) -> None: ...
def assertFormError(
self, response: Any, form: Any, field: Any, errors: Any, msg_prefix: str = ...
self,
response: Any,
form: Any,
field: Any,
errors: Any,
msg_prefix: str = ...,
) -> None: ...
def assertFormsetError(
self,
@@ -108,49 +115,33 @@ class SimpleTestCase(unittest.TestCase):
errors: Any,
msg_prefix: str = ...,
) -> None: ...
def _assert_template_used(
self,
response: Optional[Union[str, HttpResponse]],
template_name: Optional[str],
msg_prefix: str,
) -> Union[
Tuple[None, List[Any], str], Tuple[str, None, str], Tuple[None, List[str], str]
]: ...
def assertTemplateUsed(
self,
response: Optional[Any] = ...,
template_name: Optional[Any] = ...,
response: TemplateResponse = ...,
template_name: str = ...,
msg_prefix: str = ...,
count: Optional[Any] = ...,
): ...
count: None = ...,
) -> None: ...
def assertTemplateNotUsed(
self,
response: Optional[Any] = ...,
template_name: Optional[Any] = ...,
msg_prefix: str = ...,
): ...
def _assert_raises_or_warns_cm(
def assertRaisesMessage(
self,
func: Callable,
cm_attr: str,
expected_exception: Type[Exception],
expected_message: str,
) -> Iterator[Union[_AssertRaisesContext, _AssertWarnsContext]]: ...
def _assertFooMessage(
self,
func: Callable,
cm_attr: str,
expected_exception: Type[Exception],
expected_message: str,
*args: Any,
**kwargs: Any,
**kwargs: Any
) -> _GeneratorContextManager: ...
def assertRaisesMessage(
self, expected_exception: Any, expected_message: Any, *args: Any, **kwargs: Any
): ...
def assertWarnsMessage(
self, expected_warning: Any, expected_message: Any, *args: Any, **kwargs: Any
): ...
self,
expected_warning: Type[RuntimeWarning],
expected_message: str,
*args: Any,
**kwargs: Any
) -> _GeneratorContextManager: ...
def assertFieldOutput(
self,
fieldclass: Any,
@@ -160,21 +151,31 @@ class SimpleTestCase(unittest.TestCase):
field_kwargs: Optional[Any] = ...,
empty_value: str = ...,
) -> None: ...
def assertHTMLEqual(self, html1: Any, html2: Any, msg: Optional[Any] = ...) -> None: ...
def assertHTMLEqual(
self, html1: Any, html2: Any, msg: Optional[Any] = ...
) -> None: ...
def assertHTMLNotEqual(
self, html1: Any, html2: Any, msg: Optional[Any] = ...
) -> None: ...
def assertInHTML(
self, needle: Any, haystack: Any, count: Optional[Any] = ..., msg_prefix: str = ...
self,
needle: Any,
haystack: Any,
count: Optional[Any] = ...,
msg_prefix: str = ...,
) -> None: ...
def assertJSONEqual(
self, raw: Any, expected_data: Any, msg: Optional[Any] = ...
self, raw: str, expected_data: 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] = ...) -> None: ...
def assertXMLNotEqual(self, xml1: Any, xml2: Any, msg: Optional[Any] = ...) -> None: ...
def assertXMLEqual(
self, xml1: Any, xml2: Any, msg: Optional[Any] = ...
) -> None: ...
def assertXMLNotEqual(
self, xml1: Any, xml2: Any, msg: Optional[Any] = ...
) -> None: ...
class TransactionTestCase(SimpleTestCase):
reset_sequences: bool = ...
@@ -183,50 +184,37 @@ class TransactionTestCase(SimpleTestCase):
multi_db: bool = ...
serialized_rollback: bool = ...
allow_database_queries: bool = ...
def _pre_setup(self) -> None: ...
@classmethod
def _databases_names(cls, include_mirrors: bool = ...): ...
def _reset_sequences(self, db_name: Any) -> None: ...
def _fixture_setup(self) -> None: ...
def _should_reload_connections(self): ...
def _post_teardown(self) -> None: ...
def _fixture_teardown(self) -> None: ...
def assertQuerysetEqual(
self,
qs: Any,
values: Any,
transform: Any = ...,
qs: QuerySet,
values: Union[
List[int],
List[Union[str, None]],
List[Tuple[str, Type[Model], int]],
],
transform: Callable = ...,
ordered: bool = ...,
msg: Optional[Any] = ...,
): ...
msg: None = ...,
) -> None: ...
def assertNumQueries(
self,
num: Any,
func: Optional[Any] = ...,
num: int,
func: Optional[Union[Callable, Type[list]]] = ...,
*args: Any,
using: Any = ...,
**kwargs: Any,
): ...
**kwargs: Any
) -> Optional[_AssertNumQueriesContext]: ...
class TestCase(TransactionTestCase):
@classmethod
def _enter_atomics(cls): ...
@classmethod
def _rollback_atomics(cls, atomics: Any) -> None: ...
@classmethod
def setUpClass(cls): ...
def setUpClass(cls) -> None: ...
@classmethod
def tearDownClass(cls) -> None: ...
@classmethod
def setUpTestData(cls) -> None: ...
def _should_reload_connections(self): ...
atomics: Any = ...
def _fixture_setup(self): ...
def _fixture_teardown(self): ...
def _should_check_constraints(self, connection: Any): ...
class CheckCondition:
conditions: Any = ...
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: ...
@@ -241,7 +229,6 @@ class FSFilesHandler(WSGIHandler):
application: Any = ...
base_url: Any = ...
def __init__(self, application: Any) -> None: ...
def _should_handle(self, path: Any): ...
def file_path(self, url: Any): ...
def get_response(self, request: Any): ...
def serve(self, request: Any): ...
@@ -256,22 +243,28 @@ class _MediaFilesHandler(FSFilesHandler):
def get_base_url(self): ...
class LiveServerThread(threading.Thread):
host: Any = ...
port: Any = ...
is_ready: Any = ...
error: Any = ...
static_handler: Any = ...
connections_override: Any = ...
host: str = ...
port: int = ...
is_ready: threading.Event = ...
error: Optional[django.core.exceptions.ImproperlyConfigured] = ...
static_handler: Type[
Union[
django.contrib.staticfiles.handlers.StaticFilesHandler,
django.test.testcases._StaticFilesHandler,
]
] = ...
connections_override: Dict[
str, django.db.backends.sqlite3.base.DatabaseWrapper
] = ...
def __init__(
self,
host: str,
static_handler: Type[_StaticFilesHandler],
connections_override: Dict[str, DatabaseWrapper] = ...,
host: Any,
static_handler: Any,
connections_override: Optional[Any] = ...,
port: int = ...,
) -> None: ...
httpd: Any = ...
httpd: django.core.servers.basehttp.ThreadedWSGIServer = ...
def run(self) -> None: ...
def _create_server(self): ...
def terminate(self) -> None: ...
class LiveServerTestCase(TransactionTestCase):
@@ -283,12 +276,6 @@ class LiveServerTestCase(TransactionTestCase):
@classmethod
def setUpClass(cls) -> None: ...
@classmethod
def _create_server_thread(
cls, connections_override: Dict[str, DatabaseWrapper]
) -> LiveServerThread: ...
@classmethod
def _tearDownClassInternal(cls) -> None: ...
@classmethod
def tearDownClass(cls) -> None: ...
class SerializeMixin:
+127 -100
View File
@@ -1,124 +1,151 @@
from io import StringIO
from collections import OrderedDict
from contextlib import _GeneratorContextManager
from decimal import Decimal
from typing import (Any, Callable, Dict, Iterator, List, Optional, Tuple, Type,
Union)
from django.apps.registry import Apps
from django.conf import LazySettings
from django.db import DefaultConnectionProxy
from django.db.backends.dummy.base import DatabaseWrapper
from django.contrib.admin.tests import AdminSeleniumTestCase
from django.db.backends.sqlite3.base import DatabaseWrapper
from django.template.base import Template
from django.template.context import Context
from django.test.runner import DiscoverRunner
from django.test.testcases import SimpleTestCase
from django.test.testcases import (SimpleTestCase, TestCase,
_AssertNumQueriesContext)
from django.utils.safestring import SafeText
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Type, Union
def captured_output(stream_name: str) -> Iterator[StringIO]: ...
def captured_stderr() -> _GeneratorContextManager: ...
def captured_stdout() -> _GeneratorContextManager: ...
def compare_xml(want: str, got: str) -> bool: ...
def dependency_ordered(
test_databases: List[Tuple[str, Tuple[str, List[str]]]],
dependencies: Dict[str, List[str]],
) -> List[Tuple[str, Tuple[str, List[str]]]]: ...
def extend_sys_path(*paths) -> Iterator[None]: ...
def freeze_time(t: int) -> Iterator[None]: ...
def get_runner(
settings: LazySettings, test_runner_class: Optional[str] = ...
) -> Type[DiscoverRunner]: ...
def get_unique_databases_and_mirrors() -> Tuple[OrderedDict, Dict[Any, Any]]: ...
def instrumented_test_render(self: Template, context: Context) -> SafeText: ...
def require_jinja2(test_func: Callable) -> Callable: ...
def setup_databases(
verbosity: int,
interactive: bool,
keepdb: bool = ...,
debug_sql: bool = ...,
parallel: int = ...,
**kwargs,
) -> Union[
List[Tuple[DatabaseWrapper, str, bool]], List[Tuple[DatabaseWrapper, str, bool]]
]: ...
def setup_test_environment(debug: bool = ...) -> None: ...
def tag(*tags) -> Callable: ...
def teardown_databases(
old_config: List[Tuple[DatabaseWrapper, str, bool]],
verbosity: int,
parallel: int = ...,
keepdb: bool = ...,
) -> None: ...
def teardown_test_environment() -> None: ...
class Approximate:
def __eq__(self, other: Union[float, Decimal]) -> bool: ...
def __init__(self, val: Union[float, Decimal], places: int = ...) -> None: ...
val: Union[float, decimal.Decimal] = ...
places: int = ...
def __init__(self, val: Any, places: int = ...) -> None: ...
def __eq__(self, other: Any): ...
class ContextList(list):
def __getitem__(self, key: Union[str, int]) -> Any: ...
def get(self, key: Any, default: Optional[Any] = ...): ...
def __contains__(self, key: str) -> bool: ...
def keys(self): ...
class _TestState: ...
def setup_test_environment(debug: bool = ...) -> None: ...
def teardown_test_environment() -> None: ...
def get_runner(
settings: LazySettings, test_runner_class: None = ...
) -> Type[DiscoverRunner]: ...
class TestContextDecorator:
attr_name: Any = ...
kwarg_name: Any = ...
def __init__(
self, attr_name: Optional[str] = ..., kwarg_name: None = ...
) -> None: ...
def enable(self) -> None: ...
def disable(self) -> None: ...
def __enter__(self) -> Optional[Apps]: ...
def __exit__(
self, exc_type: None, exc_value: None, traceback: None
) -> None: ...
def decorate_class(
self, cls: Type[SimpleTestCase]
) -> Type[SimpleTestCase]: ...
def decorate_callable(self, func: Callable) -> Callable: ...
def __call__(
self, decorated: Union[Type[SimpleTestCase], Callable]
) -> Union[Type[SimpleTestCase], Callable]: ...
class override_settings(TestContextDecorator):
attr_name: None
kwarg_name: None
options: Dict[str, Any] = ...
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 decorate_class(
self, cls: Type[SimpleTestCase]
) -> Type[SimpleTestCase]: ...
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]]]] = ...
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 enable(self) -> None: ...
class override_system_checks(TestContextDecorator):
attr_name: None
kwarg_name: None
registry: django.core.checks.registry.CheckRegistry = ...
new_checks: List[Callable] = ...
deployment_checks: Optional[List[Callable]] = ...
def __init__(
self, new_checks: Any, deployment_checks: Optional[Any] = ...
) -> None: ...
old_checks: Set[Callable] = ...
old_deployment_checks: Set[Callable] = ...
def enable(self) -> None: ...
def disable(self) -> None: ...
class CaptureQueriesContext:
def __enter__(self) -> CaptureQueriesContext: ...
def __exit__(self, exc_type: None, exc_value: None, traceback: None) -> None: ...
def __getitem__(self, index: int) -> Dict[str, str]: ...
def __init__(
self,
connection: Union[DefaultConnectionProxy, backends.sqlite3.base.DatabaseWrapper],
) -> None: ...
connection: django.db.DefaultConnectionProxy = ...
def __init__(self, connection: DatabaseWrapper) -> None: ...
def __iter__(self): ...
def __getitem__(self, index: Any): ...
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 __exit__(
self, exc_type: None, exc_value: None, traceback: None
) -> None: ...
class ContextList:
def __contains__(self, key: str) -> bool: ...
def __getitem__(self, key: Union[str, int]) -> Any: ...
def get(self, key: str, default: None = ...) -> str: ...
class ignore_warnings(TestContextDecorator):
attr_name: None
kwarg_name: None
ignore_kwargs: Dict[
str, Union[Type[django.utils.deprecation.RemovedInDjango30Warning], str]
] = ...
filter_func: Callable = ...
def __init__(self, **kwargs: Any) -> None: ...
catch_warnings: warnings.catch_warnings = ...
def enable(self) -> None: ...
def disable(self) -> None: ...
requires_tz_support: Any
def isolate_lru_cache(lru_cache_object: Any) -> None: ...
class override_script_prefix(TestContextDecorator):
attr_name: None
kwarg_name: None
prefix: str = ...
def __init__(self, prefix: str) -> None: ...
old_prefix: str = ...
def enable(self) -> None: ...
def disable(self) -> None: ...
class LoggingCaptureMixin:
logger: Any = ...
old_stream: Any = ...
logger_output: Any = ...
def setUp(self) -> None: ...
def tearDown(self) -> None: ...
class TestContextDecorator:
def __call__(self, decorated: Any) -> Any: ...
def __enter__(self) -> Optional[Apps]: ...
def __exit__(self, exc_type: None, exc_value: None, traceback: None) -> None: ...
def __init__(
self, attr_name: Optional[str] = ..., kwarg_name: Optional[str] = ...
) -> None: ...
def decorate_callable(self, func: Callable) -> Callable: ...
def decorate_class(self, cls: Type[SimpleTestCase]) -> Type[SimpleTestCase]: ...
class ignore_warnings:
def __init__(self, **kwargs) -> None: ...
def disable(self) -> None: ...
def enable(self) -> None: ...
class isolate_apps:
def __init__(self, *installed_apps, **kwargs) -> None: ...
def disable(self) -> None: ...
class isolate_apps(TestContextDecorator):
attr_name: Optional[str]
kwarg_name: Optional[str]
installed_apps: Tuple[str] = ...
def __init__(self, *installed_apps: Any, **kwargs: Any) -> None: ...
old_apps: django.apps.registry.Apps = ...
def enable(self) -> Apps: ...
class modify_settings:
def __init__(self, *args, **kwargs) -> None: ...
def enable(self) -> None: ...
def save_options(self, test_func: Type[SimpleTestCase]) -> None: ...
class override_script_prefix:
def __init__(self, prefix: str) -> None: ...
def disable(self) -> None: ...
def enable(self) -> None: ...
class override_settings:
def __init__(self, **kwargs) -> None: ...
def decorate_class(
self, cls: Type[Union[SimpleTestCase, LoggingCaptureMixin]]
) -> Type[Union[SimpleTestCase, LoggingCaptureMixin]]: ...
def disable(self) -> None: ...
def enable(self) -> None: ...
def save_options(
self, test_func: Type[Union[SimpleTestCase, LoggingCaptureMixin]]
) -> None: ...
class override_system_checks:
def __init__(
self, new_checks: List[Callable], deployment_checks: Optional[List[Callable]] = ...
) -> None: ...
def disable(self) -> None: ...
def enable(self) -> None: ...