-
-
Notifications
You must be signed in to change notification settings - Fork 454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update django.test.runner
stubs
#1888
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ from argparse import ArgumentParser | |
from collections.abc import Iterator, Sequence | ||
from contextlib import contextmanager | ||
from io import StringIO | ||
from typing import Any, Literal | ||
from typing import Any, AnyStr, Callable, ClassVar, Generator, Literal | ||
from unittest import TestCase, TestLoader, TestSuite, TextTestResult, TextTestRunner | ||
|
||
from django.db.backends.base.base import BaseDatabaseWrapper | ||
|
@@ -36,14 +36,18 @@ class DebugSQLTextTestResult(TextTestResult): | |
def addError(self, test: Any, err: Any) -> None: ... | ||
def addFailure(self, test: Any, err: Any) -> None: ... | ||
|
||
class PDBDebugResult(TextTestResult): ... | ||
class PDBDebugResult(TextTestResult): | ||
def debug(self, error: Any) -> None: ... | ||
|
||
class DummyList: | ||
def append(self, item: Any) -> None: ... | ||
|
||
class RemoteTestResult: | ||
events: list[Any] | ||
failfast: bool | ||
shouldStop: bool | ||
testsRun: int | ||
def __init__(self) -> None: ... | ||
def __init__(self, *args: Any, **kwargs: Any) -> None: ... | ||
@property | ||
def test_index(self) -> int: ... | ||
def check_picklable(self, test: Any, err: Any) -> None: ... | ||
|
@@ -62,6 +66,7 @@ class RemoteTestResult: | |
def addSkip(self, test: Any, reason: Any) -> None: ... | ||
def addExpectedFailure(self, test: Any, err: Any) -> None: ... | ||
def addUnexpectedSuccess(self, test: Any) -> None: ... | ||
def wasSuccessful(self) -> bool: ... | ||
|
||
class RemoteTestRunner: | ||
resultclass: Any | ||
|
@@ -71,9 +76,13 @@ class RemoteTestRunner: | |
def run(self, test: Any) -> Any: ... | ||
|
||
def default_test_processes() -> int: ... | ||
def get_max_test_processes() -> int: ... | ||
def parallel_type(value: str) -> int | Literal["auto"]: ... | ||
|
||
class ParallelTestSuite(TestSuite): | ||
init_worker: Any | ||
process_setup: Callable | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we type it better? |
||
process_setup_args: tuple[Any, ...] | ||
run_subsuite: Any | ||
runner_class: Any | ||
subsuites: list[TestSuite] | ||
|
@@ -83,16 +92,30 @@ class ParallelTestSuite(TestSuite): | |
initial_settings: Any | ||
serialized_contents: Any | ||
def __init__( | ||
self, subsuites: list[TestSuite], processes: int, failfast: bool = ..., buffer: bool = ... | ||
self, | ||
subsuites: list[TestSuite], | ||
processes: int, | ||
failfast: bool = ..., | ||
debug_mode: bool = ..., | ||
buffer: bool = ..., | ||
) -> None: ... | ||
def run(self, result: Any) -> Any: ... # type: ignore[override] | ||
def initialize_suite(self) -> None: ... | ||
|
||
class Shuffler: | ||
hash_algorithm: ClassVar[str] | ||
|
||
def __init__(self, seed: int | None = ...) -> None: ... | ||
@property | ||
def seed_display(self) -> str: ... | ||
def shuffle(self, items: list[TestCase], key: Callable[[TestCase], str]) -> list[TestCase]: ... | ||
|
||
class DiscoverRunner: | ||
test_suite: type[TestSuite] | ||
parallel_test_suite: type[ParallelTestSuite] | ||
test_runner: type[TextTestRunner] | ||
test_loader: TestLoader | ||
reorder_by: tuple[SimpleTestCase, ...] | ||
reorder_by: tuple[type[TestCase], type[SimpleTestCase]] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that it should be Why? Because it would be easier to subclass and change. Or maybe even |
||
pattern: str | None | ||
top_level: str | None | ||
verbosity: int | ||
|
@@ -138,14 +161,14 @@ class DiscoverRunner: | |
def add_arguments(cls, parser: ArgumentParser) -> None: ... | ||
@property | ||
def shuffle_seed(self) -> int | None: ... | ||
def log(self, msg: str, level: int | None) -> None: ... | ||
def log(self, msg: str, level: int | None = ...) -> None: ... | ||
def setup_test_environment(self, **kwargs: Any) -> None: ... | ||
def setup_shuffler(self) -> None: ... | ||
@contextmanager | ||
def load_with_patterns(self) -> Iterator[None]: ... | ||
def load_tests_for_label(self, label: str, discover_kwargs: dict[str, str]) -> TestSuite: ... | ||
def build_suite( | ||
self, test_labels: Sequence[str] = ..., extra_tests: list[Any] | None = ..., **kwargs: Any | ||
self, test_labels: Sequence[str] | None = ..., extra_tests: list[Any] | None = ..., **kwargs: Any | ||
) -> TestSuite: ... | ||
def setup_databases(self, **kwargs: Any) -> list[tuple[BaseDatabaseWrapper, str, bool]]: ... | ||
def get_resultclass(self) -> type[TextTestResult] | None: ... | ||
|
@@ -159,12 +182,23 @@ class DiscoverRunner: | |
def get_databases(self, suite: TestSuite) -> set[str]: ... | ||
def run_tests(self, test_labels: list[str], extra_tests: list[Any] | None = ..., **kwargs: Any) -> int: ... | ||
|
||
def is_discoverable(label: str) -> bool: ... | ||
def try_importing(label: str) -> bool: ... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It returns |
||
def find_top_level(top_level: AnyStr) -> AnyStr: ... | ||
def shuffle_tests(tests: list[TestCase], shuffler: Shuffler) -> Iterator[TestCase]: ... | ||
def reorder_test_bin( | ||
tests: list[TestCase], shuffler: Shuffler | None = ..., reverse: bool = ... | ||
) -> Iterator[TestCase]: ... | ||
def reorder_tests( | ||
tests: list[TestCase], classes: tuple[type[TestCase], ...], reverse: bool = ..., shuffler: Shuffler | None = ... | ||
) -> Iterator[TestCase]: ... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you use |
||
def reorder_suite( | ||
suite: TestSuite, classes: tuple[type[TestCase], type[SimpleTestCase]], reverse: bool = ... | ||
) -> TestSuite: ... | ||
def partition_suite_by_type( | ||
suite: TestSuite, classes: tuple[type[TestCase], type[SimpleTestCase]], bins: list[OrderedSet], reverse: bool = ... | ||
) -> None: ... | ||
def partition_suite_by_case(suite: Any) -> list[Any]: ... | ||
def filter_tests_by_tags(suite: TestSuite, tags: set[str], exclude_tags: set[str]) -> TestSuite: ... | ||
def partition_suite_by_case(suite: TestSuite) -> list[TestSuite]: ... | ||
def test_match_tags(test: TestCase, tags: set[str], exclude_tags: set[str]) -> bool: ... | ||
def filter_tests_by_tags( | ||
tests: list[TestCase], tags: set[str], exclude_tags: set[str] | ||
) -> Generator[TestCase, None, None]: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add a TODO entry to sync this signature with
unittest.TestResult
?