Remove Python 3.7 branches (#11238)

This commit is contained in:
Sebastian Rittau
2024-01-05 11:39:39 +01:00
committed by GitHub
parent 4e62577002
commit 23604858a6
122 changed files with 1952 additions and 3800 deletions

View File

@@ -1,9 +1,11 @@
import sys
from unittest.async_case import *
from .case import (
FunctionTestCase as FunctionTestCase,
SkipTest as SkipTest,
TestCase as TestCase,
addModuleCleanup as addModuleCleanup,
expectedFailure as expectedFailure,
skip as skip,
skipIf as skipIf,
@@ -27,15 +29,11 @@ from .signals import (
)
from .suite import BaseTestSuite as BaseTestSuite, TestSuite as TestSuite
if sys.version_info >= (3, 8):
from unittest.async_case import *
from .case import addModuleCleanup as addModuleCleanup
if sys.version_info >= (3, 11):
from .case import doModuleCleanups as doModuleCleanups, enterModuleContext as enterModuleContext
__all__ = [
"IsolatedAsyncioTestCase",
"TestResult",
"TestCase",
"TestSuite",
@@ -57,11 +55,9 @@ __all__ = [
"getTestCaseNames",
"makeSuite",
"findTestCases",
"addModuleCleanup",
]
if sys.version_info >= (3, 8):
__all__ += ["addModuleCleanup", "IsolatedAsyncioTestCase"]
if sys.version_info >= (3, 11):
__all__ += ["enterModuleContext", "doModuleCleanups"]

View File

@@ -68,9 +68,8 @@ else:
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, tb: TracebackType | None
) -> bool | None: ...
if sys.version_info >= (3, 8):
def addModuleCleanup(__function: Callable[_P, object], *args: _P.args, **kwargs: _P.kwargs) -> None: ...
def doModuleCleanups() -> None: ...
def addModuleCleanup(__function: Callable[_P, object], *args: _P.args, **kwargs: _P.kwargs) -> None: ...
def doModuleCleanups() -> None: ...
if sys.version_info >= (3, 11):
def enterModuleContext(cm: AbstractContextManager[_T]) -> _T: ...
@@ -274,20 +273,16 @@ class TestCase:
def defaultTestResult(self) -> unittest.result.TestResult: ...
def id(self) -> str: ...
def shortDescription(self) -> str | None: ...
if sys.version_info >= (3, 8):
def addCleanup(self, __function: Callable[_P, object], *args: _P.args, **kwargs: _P.kwargs) -> None: ...
else:
def addCleanup(self, function: Callable[_P, object], *args: _P.args, **kwargs: _P.kwargs) -> None: ...
def addCleanup(self, __function: Callable[_P, object], *args: _P.args, **kwargs: _P.kwargs) -> None: ...
if sys.version_info >= (3, 11):
def enterContext(self, cm: AbstractContextManager[_T]) -> _T: ...
def doCleanups(self) -> None: ...
if sys.version_info >= (3, 8):
@classmethod
def addClassCleanup(cls, __function: Callable[_P, object], *args: _P.args, **kwargs: _P.kwargs) -> None: ...
@classmethod
def doClassCleanups(cls) -> None: ...
@classmethod
def addClassCleanup(cls, __function: Callable[_P, object], *args: _P.args, **kwargs: _P.kwargs) -> None: ...
@classmethod
def doClassCleanups(cls) -> None: ...
if sys.version_info >= (3, 11):
@classmethod

View File

@@ -12,41 +12,23 @@ _F = TypeVar("_F", bound=Callable[..., Any])
_AF = TypeVar("_AF", bound=Callable[..., Coroutine[Any, Any, Any]])
_P = ParamSpec("_P")
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",
)
else:
__all__ = (
"Mock",
"MagicMock",
"patch",
"sentinel",
"DEFAULT",
"ANY",
"call",
"create_autospec",
"FILTER_DIR",
"NonCallableMock",
"NonCallableMagicMock",
"mock_open",
"PropertyMock",
"seal",
)
__all__ = (
"Mock",
"MagicMock",
"patch",
"sentinel",
"DEFAULT",
"ANY",
"call",
"create_autospec",
"AsyncMock",
"FILTER_DIR",
"NonCallableMock",
"NonCallableMagicMock",
"mock_open",
"PropertyMock",
"seal",
)
if sys.version_info < (3, 9):
__version__: Final[str]
@@ -87,12 +69,10 @@ class _Call(tuple[Any, ...]):
def __call__(self, *args: Any, **kwargs: Any) -> _Call: ...
def __getattr__(self, attr: str) -> Any: ...
def __getattribute__(self, attr: str) -> Any: ...
if sys.version_info >= (3, 8):
@property
def args(self) -> tuple[Any, ...]: ...
@property
def kwargs(self) -> Mapping[str, Any]: ...
@property
def args(self) -> tuple[Any, ...]: ...
@property
def kwargs(self) -> Mapping[str, Any]: ...
def call_list(self) -> Any: ...
call: _Call
@@ -144,24 +124,13 @@ class NonCallableMock(Base, Any):
def __delattr__(self, name: str) -> None: ...
def __setattr__(self, name: str, value: Any) -> None: ...
def __dir__(self) -> list[str]: ...
if sys.version_info >= (3, 8):
def _calls_repr(self, prefix: str = "Calls") -> str: ...
def assert_called_with(self, *args: Any, **kwargs: Any) -> None: ...
def assert_not_called(self) -> None: ...
def assert_called_once_with(self, *args: Any, **kwargs: Any) -> None: ...
def _format_mock_failure_message(self, args: Any, kwargs: Any, action: str = "call") -> str: ...
else:
def assert_called_with(_mock_self, *args: Any, **kwargs: Any) -> None: ...
def assert_not_called(_mock_self) -> None: ...
def assert_called_once_with(_mock_self, *args: Any, **kwargs: Any) -> None: ...
def _format_mock_failure_message(self, args: Any, kwargs: Any) -> str: ...
if sys.version_info >= (3, 8):
def assert_called(self) -> None: ...
def assert_called_once(self) -> None: ...
else:
def assert_called(_mock_self) -> None: ...
def assert_called_once(_mock_self) -> None: ...
def _calls_repr(self, prefix: str = "Calls") -> str: ...
def assert_called_with(self, *args: Any, **kwargs: Any) -> None: ...
def assert_not_called(self) -> None: ...
def assert_called_once_with(self, *args: Any, **kwargs: Any) -> None: ...
def _format_mock_failure_message(self, args: Any, kwargs: Any, action: str = "call") -> str: ...
def assert_called(self) -> None: ...
def assert_called_once(self) -> None: ...
def reset_mock(self, visited: Any = None, *, return_value: bool = False, side_effect: bool = False) -> None: ...
def _extract_mock_name(self) -> str: ...
def _get_call_signature_from_name(self, name: str) -> Any: ...
@@ -198,10 +167,7 @@ class CallableMixin(Base):
_new_parent: Any | None = None,
**kwargs: Any,
) -> None: ...
if sys.version_info >= (3, 8):
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
else:
def __call__(_mock_self, *args: Any, **kwargs: Any) -> Any: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
class Mock(CallableMixin, NonCallableMock): ...
@@ -256,16 +222,12 @@ class _patch(Generic[_T]):
# arguments. See the _patch_default_new class below for this functionality.
@overload
def __call__(self, func: Callable[_P, _R]) -> Callable[_P, _R]: ...
if sys.version_info >= (3, 8):
def decoration_helper(
self, patched: _patch[Any], args: Sequence[Any], keywargs: Any
) -> _GeneratorContextManager[tuple[Sequence[Any], Any]]: ...
def decoration_helper(
self, patched: _patch[Any], args: Sequence[Any], keywargs: Any
) -> _GeneratorContextManager[tuple[Sequence[Any], Any]]: ...
def decorate_class(self, klass: _TT) -> _TT: ...
def decorate_callable(self, func: Callable[..., _R]) -> Callable[..., _R]: ...
if sys.version_info >= (3, 8):
def decorate_async_callable(self, func: Callable[..., Awaitable[_R]]) -> Callable[..., Awaitable[_R]]: ...
def decorate_async_callable(self, func: Callable[..., Awaitable[_R]]) -> Callable[..., Awaitable[_R]]: ...
def get_original(self) -> tuple[Any, bool]: ...
target: Any
temp_original: Any
@@ -277,15 +239,10 @@ class _patch(Generic[_T]):
def start(self) -> _T: ...
def stop(self) -> None: ...
if sys.version_info >= (3, 8):
_Mock: TypeAlias = MagicMock | AsyncMock
else:
_Mock: TypeAlias = MagicMock
# This class does not exist at runtime, it's a hack to make this work:
# @patch("foo")
# def bar(..., mock: MagicMock) -> None: ...
class _patch_default_new(_patch[_Mock]):
class _patch_default_new(_patch[MagicMock | AsyncMock]):
@overload
def __call__(self, func: _TT) -> _TT: ...
# Can't use the following as ParamSpec is only allowed as last parameter:
@@ -366,7 +323,7 @@ class _patcher:
autospec: Any | None = ...,
new_callable: Any | None = ...,
**kwargs: Any,
) -> _patch[_Mock]: ...
) -> _patch[MagicMock | AsyncMock]: ...
@staticmethod
def multiple(
target: Any,
@@ -388,38 +345,34 @@ class MagicMixin:
class NonCallableMagicMock(MagicMixin, NonCallableMock): ...
class MagicMock(MagicMixin, Mock): ...
if sys.version_info >= (3, 8):
class AsyncMockMixin(Base):
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
async def _execute_mock_call(self, *args: Any, **kwargs: Any) -> Any: ...
def assert_awaited(self) -> None: ...
def assert_awaited_once(self) -> None: ...
def assert_awaited_with(self, *args: Any, **kwargs: Any) -> None: ...
def assert_awaited_once_with(self, *args: Any, **kwargs: Any) -> None: ...
def assert_any_await(self, *args: Any, **kwargs: Any) -> None: ...
def assert_has_awaits(self, calls: Iterable[_Call], any_order: bool = False) -> None: ...
def assert_not_awaited(self) -> None: ...
def reset_mock(self, *args: Any, **kwargs: Any) -> None: ...
await_count: int
await_args: _Call | None
await_args_list: _CallList
class AsyncMockMixin(Base):
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
async def _execute_mock_call(self, *args: Any, **kwargs: Any) -> Any: ...
def assert_awaited(self) -> None: ...
def assert_awaited_once(self) -> None: ...
def assert_awaited_with(self, *args: Any, **kwargs: Any) -> None: ...
def assert_awaited_once_with(self, *args: Any, **kwargs: Any) -> None: ...
def assert_any_await(self, *args: Any, **kwargs: Any) -> None: ...
def assert_has_awaits(self, calls: Iterable[_Call], any_order: bool = False) -> None: ...
def assert_not_awaited(self) -> None: ...
def reset_mock(self, *args: Any, **kwargs: Any) -> None: ...
await_count: int
await_args: _Call | None
await_args_list: _CallList
class AsyncMagicMixin(MagicMixin):
def __init__(self, *args: Any, **kw: Any) -> None: ...
class AsyncMagicMixin(MagicMixin):
def __init__(self, *args: Any, **kw: Any) -> None: ...
class AsyncMock(AsyncMockMixin, AsyncMagicMixin, Mock):
# Improving the `reset_mock` signature.
# It is defined on `AsyncMockMixin` with `*args, **kwargs`, which is not ideal.
# But, `NonCallableMock` super-class has the better version.
def reset_mock(self, visited: Any = None, *, return_value: bool = False, side_effect: bool = False) -> None: ...
class AsyncMock(AsyncMockMixin, AsyncMagicMixin, Mock):
# Improving the `reset_mock` signature.
# It is defined on `AsyncMockMixin` with `*args, **kwargs`, which is not ideal.
# But, `NonCallableMock` super-class has the better version.
def reset_mock(self, visited: Any = None, *, return_value: bool = False, side_effect: bool = False) -> None: ...
class MagicProxy:
name: str
parent: Any
def __init__(self, name: str, parent: Any) -> None: ...
if sys.version_info < (3, 8):
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
def create_mock(self) -> Any: ...
def __get__(self, obj: Any, _type: Any | None = None) -> Any: ...
@@ -471,11 +424,7 @@ class _SpecState:
def mock_open(mock: Any | None = None, read_data: Any = "") -> Any: ...
class PropertyMock(Mock):
if sys.version_info >= (3, 8):
def __get__(self, obj: _T, obj_type: type[_T] | None = None) -> Self: ...
else:
def __get__(self, obj: _T, obj_type: type[_T] | None) -> Self: ...
def __get__(self, obj: _T, obj_type: type[_T] | None = None) -> Self: ...
def __set__(self, obj: Any, val: Any) -> None: ...
def seal(mock: Any) -> None: ...