Restore stubtest 0.930 (#6663)

This commit is contained in:
Sebastian Rittau
2021-12-23 05:18:19 +01:00
committed by GitHub
parent 9bf2ceb963
commit 3fb2bcd4c1
51 changed files with 478 additions and 123 deletions

View File

@@ -10,15 +10,25 @@ from .case import (
skipIf as skipIf,
skipUnless as skipUnless,
)
from .loader import (
TestLoader as TestLoader,
defaultTestLoader as defaultTestLoader,
findTestCases as findTestCases,
getTestCaseNames as getTestCaseNames,
makeSuite as makeSuite,
)
from .main import TestProgram as TestProgram, main as main
from .result import TestResult as TestResult
from .runner import TextTestResult as TextTestResult, TextTestRunner as TextTestRunner
from .signals import (
installHandler as installHandler,
registerResult as registerResult,
removeHandler as removeHandler,
removeResult as removeResult,
)
from .suite import BaseTestSuite as BaseTestSuite, TestSuite as TestSuite
if sys.version_info >= (3, 8):
from .case import addModuleCleanup as addModuleCleanup
from unittest.loader import *
from unittest.main import *
from unittest.result import TestResult as TestResult
from unittest.runner import *
from unittest.signals import *
from unittest.suite import *
def load_tests(loader: TestLoader, tests: TestSuite, pattern: str | None) -> TestSuite: ...

View File

@@ -32,6 +32,8 @@ if sys.version_info >= (3, 9):
_E = TypeVar("_E", bound=BaseException)
_FT = TypeVar("_FT", bound=Callable[..., Any])
DIFF_OMITTED: str
class _BaseTestCaseContext:
def __init__(self, test_case: TestCase) -> None: ...

View File

@@ -3,11 +3,13 @@ import unittest.case
import unittest.result
import unittest.suite
from types import ModuleType
from typing import Any, Callable, List, Sequence, Type
from typing import Any, Callable, List, Pattern, Sequence, Type
_SortComparisonMethod = Callable[[str, str], int]
_SuiteClass = Callable[[List[unittest.case.TestCase]], unittest.suite.TestSuite]
VALID_MODULE_NAME: Pattern[str]
class TestLoader:
errors: list[Type[BaseException]]
testMethodPrefix: str

View File

@@ -6,6 +6,9 @@ import unittest.suite
from types import ModuleType
from typing import Any, Iterable, Protocol, Type
MAIN_EXAMPLES: str
MODULE_EXAMPLES: str
class _TestRunner(Protocol):
def run(self, test: unittest.suite.TestSuite | unittest.case.TestCase) -> unittest.result.TestResult: ...

View File

@@ -5,23 +5,57 @@ _T = TypeVar("_T")
_TT = TypeVar("_TT", bound=Type[Any])
_R = TypeVar("_R")
__all__ = [
"Mock",
"MagicMock",
"patch",
"sentinel",
"DEFAULT",
"ANY",
"call",
"create_autospec",
"AsyncMock",
"FILTER_DIR",
"NonCallableMock",
"NonCallableMagicMock",
"mock_open",
"PropertyMock",
"seal",
]
if sys.version_info >= (3, 8):
__all__ = (
"Mock",
"MagicMock",
"patch",
"sentinel",
"DEFAULT",
"ANY",
"call",
"create_autospec",
"AsyncMock",
"FILTER_DIR",
"NonCallableMock",
"NonCallableMagicMock",
"mock_open",
"PropertyMock",
"seal",
)
elif sys.version_info >= (3, 7):
__all__ = (
"Mock",
"MagicMock",
"patch",
"sentinel",
"DEFAULT",
"ANY",
"call",
"create_autospec",
"FILTER_DIR",
"NonCallableMock",
"NonCallableMagicMock",
"mock_open",
"PropertyMock",
"seal",
)
else:
__all__ = (
"Mock",
"MagicMock",
"patch",
"sentinel",
"DEFAULT",
"ANY",
"call",
"create_autospec",
"FILTER_DIR",
"NonCallableMock",
"NonCallableMagicMock",
"mock_open",
"PropertyMock",
)
__version__: str
FILTER_DIR: Any
@@ -39,7 +73,7 @@ class _Sentinel:
sentinel: Any
DEFAULT: Any
class _Call(Tuple[Any, ...]):
class _Call(tuple[Any, ...]):
def __new__(
cls, value: Any = ..., name: Any | None = ..., parent: Any | None = ..., two: bool = ..., from_kall: bool = ...
) -> Any: ...
@@ -53,6 +87,11 @@ class _Call(Tuple[Any, ...]):
__ne__: Any
def __call__(self, *args: Any, **kwargs: Any) -> _Call: ...
def __getattr__(self, attr: Any) -> Any: ...
if sys.version_info >= (3, 8):
@property
def args(self): ...
@property
def kwargs(self): ...
def call_list(self) -> Any: ...
call: _Call
@@ -60,12 +99,6 @@ call: _Call
class _CallList(List[_Call]):
def __contains__(self, value: Any) -> bool: ...
class _MockIter:
obj: Any
def __init__(self, obj: Any) -> None: ...
def __iter__(self) -> Any: ...
def __next__(self) -> Any: ...
class Base:
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
@@ -141,7 +174,10 @@ class CallableMixin(Base):
_new_parent: Any | None = ...,
**kwargs: Any,
) -> None: ...
def __call__(_mock_self, *args: Any, **kwargs: Any) -> Any: ...
if sys.version_info >= (3, 8):
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
else:
def __call__(_mock_self, *args: Any, **kwargs: Any) -> Any: ...
class Mock(CallableMixin, NonCallableMock): ...
@@ -160,23 +196,41 @@ class _patch(Generic[_T]):
additional_patchers: Any
# If new==DEFAULT, self is _patch[Any]. Ideally we'd be able to add an overload for it so that self is _patch[MagicMock],
# but that's impossible with the current type system.
def __init__(
self: _patch[_T],
getter: Callable[[], Any],
attribute: str,
new: _T,
spec: Any | None,
create: bool,
spec_set: Any | None,
autospec: Any | None,
new_callable: Any | None,
kwargs: Mapping[str, Any],
) -> None: ...
if sys.version_info >= (3, 10):
def __init__(
self: _patch[_T],
getter: Callable[[], Any],
attribute: str,
new: _T,
spec: Any | None,
create: bool,
spec_set: Any | None,
autospec: Any | None,
new_callable: Any | None,
kwargs: Mapping[str, Any],
*,
unsafe: bool = ...,
) -> None: ...
else:
def __init__(
self: _patch[_T],
getter: Callable[[], Any],
attribute: str,
new: _T,
spec: Any | None,
create: bool,
spec_set: Any | None,
autospec: Any | None,
new_callable: Any | None,
kwargs: Mapping[str, Any],
) -> None: ...
def copy(self) -> _patch[_T]: ...
@overload
def __call__(self, func: _TT) -> _TT: ...
@overload
def __call__(self, func: Callable[..., _R]) -> Callable[..., _R]: ...
if sys.version_info >= (3, 8):
def decoration_helper(self, patched, args, keywargs): ...
def decorate_class(self, klass: _TT) -> _TT: ...
def decorate_callable(self, func: Callable[..., _R]) -> Callable[..., _R]: ...
if sys.version_info >= (3, 8):
@@ -357,10 +411,11 @@ if sys.version_info >= (3, 8):
class MagicProxy:
name: Any
parent: Any
def __init__(self, name: Any, parent: Any) -> None: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
def create_mock(self) -> Any: ...
def __get__(self, obj: Any, _type: Any | None = ...) -> Any: ...
def __init__(self, name, parent) -> None: ...
if sys.version_info < (3, 8):
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
def create_mock(self): ...
def __get__(self, obj, _type: Any | None = ...): ...
class _ANY:
def __eq__(self, other: Any) -> bool: ...

View File

@@ -6,6 +6,9 @@ _SysExcInfoType = Union[Tuple[Type[BaseException], BaseException, TracebackType]
_F = TypeVar("_F", bound=Callable[..., Any])
STDOUT_LINE: str
STDERR_LINE: str
# undocumented
def failfast(method: _F) -> _F: ...