|
| 1 | +# Stubs for unittest.mock |
| 2 | + |
| 3 | +import sys |
| 4 | +from typing import Any, Optional |
| 5 | + |
| 6 | +if sys.version_info >= (3, 3): |
| 7 | + FILTER_DIR = ... # type: Any |
| 8 | + |
| 9 | + class _slotted: ... |
| 10 | + |
| 11 | + class _SentinelObject: |
| 12 | + name = ... # type: Any |
| 13 | + def __init__(self, name: Any) -> None: ... |
| 14 | + |
| 15 | + class _Sentinel: |
| 16 | + def __init__(self) -> None: ... |
| 17 | + def __getattr__(self, name: str) -> Any: ... |
| 18 | + |
| 19 | + sentinel = ... # type: Any |
| 20 | + DEFAULT = ... # type: Any |
| 21 | + |
| 22 | + class _CallList(list): |
| 23 | + def __contains__(self, value: Any) -> bool: ... |
| 24 | + |
| 25 | + class _MockIter: |
| 26 | + obj = ... # type: Any |
| 27 | + def __init__(self, obj: Any) -> None: ... |
| 28 | + def __iter__(self) -> Any: ... |
| 29 | + def __next__(self) -> Any: ... |
| 30 | + |
| 31 | + class Base: |
| 32 | + def __init__(self, *args: Any, **kwargs: Any) -> None: ... |
| 33 | + |
| 34 | + # TODO: Get rid of the # type: ignore below. |
| 35 | + # It is currently required to shut up mypy when run with `--strict` |
| 36 | + # or `--disallow-subclassing-any`. The `Any` base class is currently |
| 37 | + # the only way to allow passing an instance of `Mock` to functions |
| 38 | + # expecting other classes (as is Mock's purpose) |
| 39 | + class NonCallableMock(Any): # type: ignore |
| 40 | + def __new__(cls, *args: Any, **kw: Any) -> Any: ... |
| 41 | + def __init__(self, spec: Optional[Any] = ..., wraps: Optional[Any] = ..., name: Optional[Any] = ..., spec_set: Optional[Any] = ..., parent: Optional[Any] = ..., _spec_state: Optional[Any] = ..., _new_name: Any = ..., _new_parent: Optional[Any] = ..., _spec_as_instance: Any = ..., _eat_self: Optional[Any] = ..., unsafe: Any = ..., **kwargs: Any) -> None: ... |
| 42 | + def attach_mock(self, mock: Any, attribute: Any) -> Any: ... |
| 43 | + def mock_add_spec(self, spec: Any, spec_set: Any = ...) -> Any: ... |
| 44 | + return_value = ... # type: Any |
| 45 | + __class__ = ... # type: type |
| 46 | + called = ... # type: Any |
| 47 | + call_count = ... # type: Any |
| 48 | + call_args = ... # type: Any |
| 49 | + call_args_list = ... # type: Any |
| 50 | + mock_calls = ... # type: Any |
| 51 | + side_effect = ... # type: Any |
| 52 | + method_calls = ... # type: Any |
| 53 | + def reset_mock(self, visited: Optional[bool] = ...) -> None: ... |
| 54 | + def configure_mock(self, **kwargs: Any) -> None: ... |
| 55 | + def __getattr__(self, name: Any) -> Any: ... |
| 56 | + def __dir__(self) -> Any: ... |
| 57 | + def __setattr__(self, name: Any, value: Any) -> None: ... |
| 58 | + def __delattr__(self, name: Any) -> None: ... |
| 59 | + def assert_not_called(_mock_self) -> None: ... |
| 60 | + def assert_called_with(_mock_self, *args: Any, **kwargs: Any) -> None: ... |
| 61 | + def assert_called_once_with(_mock_self, *args: Any, **kwargs: Any) -> None: ... |
| 62 | + def assert_has_calls(self, calls: Any, any_order: bool = ...) -> None: ... |
| 63 | + def assert_any_call(self, *args: Any, **kwargs: Any) -> None: ... |
| 64 | + |
| 65 | + class CallableMixin(Base): |
| 66 | + side_effect = ... # type: Any |
| 67 | + def __init__(self, spec: Optional[Any] = ..., side_effect: Optional[Any] = ..., return_value: Any = ..., wraps: Optional[Any] = ..., name: Optional[Any] = ..., spec_set: Optional[Any] = ..., parent: Optional[Any] = ..., _spec_state: Optional[Any] = ..., _new_name: Any = ..., _new_parent: Optional[Any] = ..., **kwargs: Any) -> None: ... |
| 68 | + def __call__(_mock_self, *args: Any, **kwargs: Any) -> Any: ... |
| 69 | + |
| 70 | + class Mock(CallableMixin, NonCallableMock): |
| 71 | + def __init__(self, spec: Any = ..., spec_set: Any = ..., side_effect: Any = ..., return_value: Any = ..., wraps: Any = ..., name: Any = ..., **kwargs: Any) -> None: ... |
| 72 | + |
| 73 | + class _patch: |
| 74 | + attribute_name = ... # type: Any |
| 75 | + getter = ... # type: Any |
| 76 | + attribute = ... # type: Any |
| 77 | + new = ... # type: Any |
| 78 | + new_callable = ... # type: Any |
| 79 | + spec = ... # type: Any |
| 80 | + create = ... # type: bool |
| 81 | + has_local = ... # type: Any |
| 82 | + spec_set = ... # type: Any |
| 83 | + autospec = ... # type: Any |
| 84 | + kwargs = ... # type: Any |
| 85 | + additional_patchers = ... # type: Any |
| 86 | + def __init__(self, getter: Any, attribute: Any, new: Any, spec: Any, create: Any, spec_set: Any, autospec: Any, new_callable: Any, kwargs: Any) -> None: ... |
| 87 | + def copy(self) -> Any: ... |
| 88 | + def __call__(self, func: Any) -> Any: ... |
| 89 | + def decorate_class(self, klass: Any) -> Any: ... |
| 90 | + def decorate_callable(self, func: Any) -> Any: ... |
| 91 | + def get_original(self) -> Any: ... |
| 92 | + target = ... # type: Any |
| 93 | + temp_original = ... # type: Any |
| 94 | + is_local = ... # type: Any |
| 95 | + def __enter__(self) -> Any: ... |
| 96 | + def __exit__(self, *exc_info: Any) -> Any: ... |
| 97 | + def start(self) -> Any: ... |
| 98 | + def stop(self) -> Any: ... |
| 99 | + |
| 100 | + class _patch_dict: |
| 101 | + in_dict = ... # type: Any |
| 102 | + values = ... # type: Any |
| 103 | + clear = ... # type: Any |
| 104 | + def __init__(self, in_dict: Any, values: Any = ..., clear: Any = ..., **kwargs: Any) -> None: ... |
| 105 | + def __call__(self, f: Any) -> Any: ... |
| 106 | + def decorate_class(self, klass: Any) -> Any: ... |
| 107 | + def __enter__(self) -> Any: ... |
| 108 | + def __exit__(self, *args: Any) -> Any: ... |
| 109 | + start = ... # type: Any |
| 110 | + stop = ... # type: Any |
| 111 | + |
| 112 | + class _patcher: |
| 113 | + TEST_PREFIX = ... # type: str |
| 114 | + dict = ... # type: Type[_patch_dict] |
| 115 | + def __call__(self, target: Any, new: Optional[Any] = ..., spec: Optional[Any] = ..., create: bool = ..., spec_set: Optional[Any] = ..., autospec: Optional[Any] = ..., new_callable: Optional[Any] = ..., **kwargs: Any) -> Any: ... |
| 116 | + def object(self, target: Any, attribute: str, new: Optional[Any] = ..., spec: Optional[Any] = ..., create: bool = ..., spec_set: Optional[Any] = ..., autospec: Optional[Any] = ..., new_callable: Optional[Any] = ..., **kwargs: Any) -> _patch: ... |
| 117 | + def multiple(self, target: Any, spec: Optional[Any] = ..., create: bool = ..., spec_set: Optional[Any] = ..., autospec: Optional[Any] = ..., new_callable: Optional[Any] = ..., **kwargs: Any) -> Any: ... |
| 118 | + def stopall(self) -> None: ... |
| 119 | + |
| 120 | + patch = ... # type: _patcher |
| 121 | + |
| 122 | + class MagicMixin: |
| 123 | + def __init__(self, *args: Any, **kw: Any) -> None: ... |
| 124 | + |
| 125 | + class NonCallableMagicMock(MagicMixin, NonCallableMock): |
| 126 | + def __init__(self) -> None: ... |
| 127 | + def mock_add_spec(self, spec: Any, spec_set: Any = ...) -> Any: ... |
| 128 | + |
| 129 | + class MagicMock(MagicMixin, Mock): |
| 130 | + def __init__(self, spec: Any = ..., spec_set: Any = ..., side_effect: Any = ..., return_value: Any = ..., wraps: Any = ..., name: Any = ..., **kwargs: Any) -> None: ... |
| 131 | + def mock_add_spec(self, spec: Any, spec_set: Any = ...) -> Any: ... |
| 132 | + |
| 133 | + class MagicProxy: |
| 134 | + name = ... # type: Any |
| 135 | + parent = ... # type: Any |
| 136 | + def __init__(self, name: Any, parent: Any) -> None: ... |
| 137 | + def __call__(self, *args: Any, **kwargs: Any) -> Any: ... |
| 138 | + def create_mock(self) -> Any: ... |
| 139 | + def __get__(self, obj: Any, _type: Optional[Any] = ...) -> Any: ... |
| 140 | + |
| 141 | + class _ANY: |
| 142 | + def __eq__(self, other: Any) -> bool: ... |
| 143 | + def __ne__(self, other: Any) -> bool: ... |
| 144 | + |
| 145 | + ANY = ... # type: Any |
| 146 | + |
| 147 | + class _Call(tuple): |
| 148 | + def __new__(cls, value: Any = ..., name: Optional[Any] = ..., parent: Optional[Any] = ..., two: bool = ..., from_kall: bool = ...) -> Any: ... |
| 149 | + name = ... # type: Any |
| 150 | + parent = ... # type: Any |
| 151 | + from_kall = ... # type: Any |
| 152 | + def __init__(self, value: Any = ..., name: Optional[Any] = ..., parent: Optional[Any] = ..., two: bool = ..., from_kall: bool = ...) -> None: ... |
| 153 | + def __eq__(self, other: Any) -> bool: ... |
| 154 | + __ne__ = ... # type: Any |
| 155 | + def __call__(self, *args: Any, **kwargs: Any) -> Any: ... |
| 156 | + def __getattr__(self, attr: Any) -> Any: ... |
| 157 | + def count(self, *args: Any, **kwargs: Any) -> Any: ... |
| 158 | + def index(self, *args: Any, **kwargs: Any) -> Any: ... |
| 159 | + def call_list(self) -> Any: ... |
| 160 | + |
| 161 | + call = ... # type: Any |
| 162 | + |
| 163 | + def create_autospec(spec: Any, spec_set: Any = ..., instance: Any = ..., _parent: Optional[Any] = ..., _name: Optional[Any] = ..., **kwargs: Any) -> Any: ... |
| 164 | + |
| 165 | + class _SpecState: |
| 166 | + spec = ... # type: Any |
| 167 | + ids = ... # type: Any |
| 168 | + spec_set = ... # type: Any |
| 169 | + parent = ... # type: Any |
| 170 | + instance = ... # type: Any |
| 171 | + name = ... # type: Any |
| 172 | + def __init__(self, spec: Any, spec_set: Any = ..., parent: Optional[Any] = ..., name: Optional[Any] = ..., ids: Optional[Any] = ..., instance: Any = ...) -> None: ... |
| 173 | + |
| 174 | + def mock_open(mock: Optional[Any] = ..., read_data: Any = ...) -> Any: ... |
| 175 | + |
| 176 | + class PropertyMock(Mock): |
| 177 | + def __get__(self, obj: Any, obj_type: Any) -> Any: ... |
| 178 | + def __set__(self, obj: Any, val: Any) -> Any: ... |
| 179 | + |
| 180 | +if sys.version_info >= (3, 7): |
| 181 | + def seal(mock: Any) -> None: ... |
0 commit comments