Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 67 additions & 21 deletions stdlib/3/unittest/mock.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,24 @@ class _Sentinel:
sentinel: Any
DEFAULT: Any

class _CallList(List[_T]):
class _Call(Tuple[Any, ...]):
def __new__(cls, value: Any = ..., name: Optional[Any] = ..., parent: Optional[Any] = ..., two: bool = ..., from_kall: bool = ...) -> Any: ...
name: Any
parent: Any
from_kall: Any
def __init__(self, value: Any = ..., name: Optional[Any] = ..., parent: Optional[Any] = ..., two: bool = ..., from_kall: bool = ...) -> None: ...
def __eq__(self, other: Any) -> bool: ...
__ne__: Any
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
def __getattr__(self, attr: Any) -> Any: ...
def count(self, *args: Any, **kwargs: Any) -> Any: ...
def index(self, *args: Any, **kwargs: Any) -> Any: ...
def call_list(self) -> Any: ...

call: Any


class _CallList(List[_Call]):
def __contains__(self, value: Any) -> bool: ...

class _MockIter:
Expand All @@ -32,10 +49,55 @@ class _MockIter:
class Base:
def __init__(self, *args: Any, **kwargs: Any) -> None: ...

# TODO: Defining this and other mock classes as classes in this stub causes
# many false positives with mypy and production code. See if we can
# improve mypy somehow and use a class with an "Any" base class.
NonCallableMock = Any

class NonCallableMock(Base, Any): # type: ignore
def __getattr__(self, name: str) -> Any: ...
if sys.version_info >= (3, 8):
def _calls_repr(self, prefix: str = ...) -> 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 = ...) -> str: ...
elif sys.version_info >= (3, 5):
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_once(self) -> None: ...
elif sys.version_info >= (3, 6):
def assert_called_once(_mock_self) -> None: ...

if sys.version_info >= (3, 6):
def reset_mock(self, visited: Any = ..., *, return_value: bool = ..., side_effect: bool = ...) -> None: ...
elif sys.version_info >= (3, 5):
def reset_mock(self, visited: Any = ...) -> None: ...

if sys.version_info >= (3, 7):
def _extract_mock_name(self) -> str: ...
def _get_call_signature_from_name(self, name: str) -> Any: ...

def assert_any_call(self, *args: Any, **kwargs: Any) -> None: ...
def assert_has_calls(self, calls: _CallList, any_order: bool = ...) -> None: ...
def mock_add_spec(self, spec: Any, spec_set: bool = ...) -> None: ...
def _mock_add_spec(self, spec: Any, spec_set, _spec_as_instance: bool = ..., _eat_self: bool = ...) -> None: ...
def attach_mock(self, mock: NonCallableMock, attribute: str) -> None: ...
def configure_mock(self, **kwargs: Any) -> None: ...
return_value: Any
side_effect: Any
called: bool
call_count: int
call_args: Any
call_args_list: _CallList
mock_calls: _CallList
def _format_mock_call_signature(self, args: Any, kwargs: Any) -> str: ...
def _call_matcher(self, _call: Tuple[_Call, ...]) -> _Call: ...
def _get_child_mock(self, **kw: Any) -> NonCallableMock: ...


class CallableMixin(Base):
side_effect: Any
Expand Down Expand Up @@ -115,22 +177,6 @@ class _ANY:

ANY: Any

class _Call(Tuple[Any, ...]):
def __new__(cls, value: Any = ..., name: Optional[Any] = ..., parent: Optional[Any] = ..., two: bool = ..., from_kall: bool = ...) -> Any: ...
name: Any
parent: Any
from_kall: Any
def __init__(self, value: Any = ..., name: Optional[Any] = ..., parent: Optional[Any] = ..., two: bool = ..., from_kall: bool = ...) -> None: ...
def __eq__(self, other: Any) -> bool: ...
__ne__: Any
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
def __getattr__(self, attr: Any) -> Any: ...
def count(self, *args: Any, **kwargs: Any) -> Any: ...
def index(self, *args: Any, **kwargs: Any) -> Any: ...
def call_list(self) -> Any: ...

call: Any

def create_autospec(spec: Any, spec_set: Any = ..., instance: Any = ..., _parent: Optional[Any] = ..., _name: Optional[Any] = ..., **kwargs: Any) -> Any: ...

class _SpecState:
Expand Down
88 changes: 67 additions & 21 deletions third_party/2and3/mock.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,24 @@ class _Sentinel:
sentinel: Any
DEFAULT: Any

class _CallList(List[_T]):
class _Call(Tuple[Any, ...]):
def __new__(cls, value: Any = ..., name: Optional[Any] = ..., parent: Optional[Any] = ..., two: bool = ..., from_kall: bool = ...) -> Any: ...
name: Any
parent: Any
from_kall: Any
def __init__(self, value: Any = ..., name: Optional[Any] = ..., parent: Optional[Any] = ..., two: bool = ..., from_kall: bool = ...) -> None: ...
def __eq__(self, other: Any) -> bool: ...
__ne__: Any
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
def __getattr__(self, attr: Any) -> Any: ...
def count(self, *args: Any, **kwargs: Any) -> Any: ...
def index(self, *args: Any, **kwargs: Any) -> Any: ...
def call_list(self) -> Any: ...

call: Any


class _CallList(List[_Call]):
def __contains__(self, value: Any) -> bool: ...

class _MockIter:
Expand All @@ -32,10 +49,55 @@ class _MockIter:
class Base:
def __init__(self, *args: Any, **kwargs: Any) -> None: ...

# TODO: Defining this and other mock classes as classes in this stub causes
# many false positives with mypy and production code. See if we can
# improve mypy somehow and use a class with an "Any" base class.
NonCallableMock = Any

class NonCallableMock(Base, Any): # type: ignore
def __getattr__(self, name: str) -> Any: ...
if sys.version_info >= (3, 8):
def _calls_repr(self, prefix: str = ...) -> 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 = ...) -> str: ...
elif sys.version_info >= (3, 5):
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_once(self) -> None: ...
elif sys.version_info >= (3, 6):
def assert_called_once(_mock_self) -> None: ...

if sys.version_info >= (3, 6):
def reset_mock(self, visited: Any = ..., *, return_value: bool = ..., side_effect: bool = ...) -> None: ...
elif sys.version_info >= (3, 5):
def reset_mock(self, visited: Any = ...) -> None: ...

if sys.version_info >= (3, 7):
def _extract_mock_name(self) -> str: ...
def _get_call_signature_from_name(self, name: str) -> Any: ...

def assert_any_call(self, *args: Any, **kwargs: Any) -> None: ...
def assert_has_calls(self, calls: _CallList, any_order: bool = ...) -> None: ...
def mock_add_spec(self, spec: Any, spec_set: bool = ...) -> None: ...
def _mock_add_spec(self, spec: Any, spec_set, _spec_as_instance: bool = ..., _eat_self: bool = ...) -> None: ...
def attach_mock(self, mock: NonCallableMock, attribute: str) -> None: ...
def configure_mock(self, **kwargs: Any) -> None: ...
return_value: Any
side_effect: Any
called: bool
call_count: int
call_args: Any
call_args_list: _CallList
mock_calls: _CallList
def _format_mock_call_signature(self, args: Any, kwargs: Any) -> str: ...
def _call_matcher(self, _call: Tuple[_Call, ...]) -> _Call: ...
def _get_child_mock(self, **kw: Any) -> NonCallableMock: ...


class CallableMixin(Base):
side_effect: Any
Expand Down Expand Up @@ -115,22 +177,6 @@ class _ANY:

ANY: Any

class _Call(Tuple[Any, ...]):
def __new__(cls, value: Any = ..., name: Optional[Any] = ..., parent: Optional[Any] = ..., two: bool = ..., from_kall: bool = ...) -> Any: ...
name: Any
parent: Any
from_kall: Any
def __init__(self, value: Any = ..., name: Optional[Any] = ..., parent: Optional[Any] = ..., two: bool = ..., from_kall: bool = ...) -> None: ...
def __eq__(self, other: Any) -> bool: ...
__ne__: Any
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
def __getattr__(self, attr: Any) -> Any: ...
def count(self, *args: Any, **kwargs: Any) -> Any: ...
def index(self, *args: Any, **kwargs: Any) -> Any: ...
def call_list(self) -> Any: ...

call: Any

def create_autospec(spec: Any, spec_set: Any = ..., instance: Any = ..., _parent: Optional[Any] = ..., _name: Optional[Any] = ..., **kwargs: Any) -> Any: ...

class _SpecState:
Expand Down