mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-18 01:45:59 +08:00
better stubs
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user