massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stdlib / unittest / mock.pyi
1 import sys
2 from typing import Any, Callable, Generic, Iterable, List, Mapping, Sequence, Tuple, Type, TypeVar, overload
3
4 _T = TypeVar("_T")
5 _TT = TypeVar("_TT", bound=Type[Any])
6 _R = TypeVar("_R")
7
8 __all__ = [
9     "Mock",
10     "MagicMock",
11     "patch",
12     "sentinel",
13     "DEFAULT",
14     "ANY",
15     "call",
16     "create_autospec",
17     "AsyncMock",
18     "FILTER_DIR",
19     "NonCallableMock",
20     "NonCallableMagicMock",
21     "mock_open",
22     "PropertyMock",
23     "seal",
24 ]
25 __version__: str
26
27 FILTER_DIR: Any
28
29 class _slotted: ...
30
31 class _SentinelObject:
32     name: Any
33     def __init__(self, name: Any) -> None: ...
34
35 class _Sentinel:
36     def __init__(self) -> None: ...
37     def __getattr__(self, name: str) -> Any: ...
38
39 sentinel: Any
40 DEFAULT: Any
41
42 class _Call(Tuple[Any, ...]):
43     def __new__(
44         cls, value: Any = ..., name: Any | None = ..., parent: Any | None = ..., two: bool = ..., from_kall: bool = ...
45     ) -> Any: ...
46     name: Any
47     parent: Any
48     from_kall: Any
49     def __init__(
50         self, value: Any = ..., name: Any | None = ..., parent: Any | None = ..., two: bool = ..., from_kall: bool = ...
51     ) -> None: ...
52     def __eq__(self, other: Any) -> bool: ...
53     __ne__: Any
54     def __call__(self, *args: Any, **kwargs: Any) -> _Call: ...
55     def __getattr__(self, attr: Any) -> Any: ...
56     def count(self, *args: Any, **kwargs: Any) -> Any: ...
57     def index(self, *args: Any, **kwargs: Any) -> Any: ...
58     def call_list(self) -> Any: ...
59
60 call: _Call
61
62 class _CallList(List[_Call]):
63     def __contains__(self, value: Any) -> bool: ...
64
65 class _MockIter:
66     obj: Any
67     def __init__(self, obj: Any) -> None: ...
68     def __iter__(self) -> Any: ...
69     def __next__(self) -> Any: ...
70
71 class Base:
72     def __init__(self, *args: Any, **kwargs: Any) -> None: ...
73
74 class NonCallableMock(Base, Any):  # type: ignore
75     def __new__(__cls, *args: Any, **kw: Any) -> NonCallableMock: ...
76     def __init__(
77         self,
78         spec: list[str] | object | Type[object] | None = ...,
79         wraps: Any | None = ...,
80         name: str | None = ...,
81         spec_set: list[str] | object | Type[object] | None = ...,
82         parent: NonCallableMock | None = ...,
83         _spec_state: Any | None = ...,
84         _new_name: str = ...,
85         _new_parent: NonCallableMock | None = ...,
86         _spec_as_instance: bool = ...,
87         _eat_self: bool | None = ...,
88         unsafe: bool = ...,
89         **kwargs: Any,
90     ) -> None: ...
91     def __getattr__(self, name: str) -> Any: ...
92     if sys.version_info >= (3, 8):
93         def _calls_repr(self, prefix: str = ...) -> str: ...
94         def assert_called_with(self, *args: Any, **kwargs: Any) -> None: ...
95         def assert_not_called(self) -> None: ...
96         def assert_called_once_with(self, *args: Any, **kwargs: Any) -> None: ...
97         def _format_mock_failure_message(self, args: Any, kwargs: Any, action: str = ...) -> str: ...
98     else:
99         def assert_called_with(_mock_self, *args: Any, **kwargs: Any) -> None: ...
100         def assert_not_called(_mock_self) -> None: ...
101         def assert_called_once_with(_mock_self, *args: Any, **kwargs: Any) -> None: ...
102         def _format_mock_failure_message(self, args: Any, kwargs: Any) -> str: ...
103     if sys.version_info >= (3, 8):
104         def assert_called(self) -> None: ...
105         def assert_called_once(self) -> None: ...
106     else:
107         def assert_called(_mock_self) -> None: ...
108         def assert_called_once(_mock_self) -> None: ...
109     def reset_mock(self, visited: Any = ..., *, return_value: bool = ..., side_effect: bool = ...) -> None: ...
110     if sys.version_info >= (3, 7):
111         def _extract_mock_name(self) -> str: ...
112         def _get_call_signature_from_name(self, name: str) -> Any: ...
113     def assert_any_call(self, *args: Any, **kwargs: Any) -> None: ...
114     def assert_has_calls(self, calls: Sequence[_Call], any_order: bool = ...) -> None: ...
115     def mock_add_spec(self, spec: Any, spec_set: bool = ...) -> None: ...
116     def _mock_add_spec(self, spec: Any, spec_set: bool, _spec_as_instance: bool = ..., _eat_self: bool = ...) -> None: ...
117     def attach_mock(self, mock: NonCallableMock, attribute: str) -> None: ...
118     def configure_mock(self, **kwargs: Any) -> None: ...
119     return_value: Any
120     side_effect: Any
121     called: bool
122     call_count: int
123     call_args: Any
124     call_args_list: _CallList
125     mock_calls: _CallList
126     def _format_mock_call_signature(self, args: Any, kwargs: Any) -> str: ...
127     def _call_matcher(self, _call: Tuple[_Call, ...]) -> _Call: ...
128     def _get_child_mock(self, **kw: Any) -> NonCallableMock: ...
129
130 class CallableMixin(Base):
131     side_effect: Any
132     def __init__(
133         self,
134         spec: Any | None = ...,
135         side_effect: Any | None = ...,
136         return_value: Any = ...,
137         wraps: Any | None = ...,
138         name: Any | None = ...,
139         spec_set: Any | None = ...,
140         parent: Any | None = ...,
141         _spec_state: Any | None = ...,
142         _new_name: Any = ...,
143         _new_parent: Any | None = ...,
144         **kwargs: Any,
145     ) -> None: ...
146     def __call__(_mock_self, *args: Any, **kwargs: Any) -> Any: ...
147
148 class Mock(CallableMixin, NonCallableMock): ...
149
150 class _patch(Generic[_T]):
151     attribute_name: Any
152     getter: Callable[[], Any]
153     attribute: str
154     new: _T
155     new_callable: Any
156     spec: Any
157     create: bool
158     has_local: Any
159     spec_set: Any
160     autospec: Any
161     kwargs: Mapping[str, Any]
162     additional_patchers: Any
163     # If new==DEFAULT, self is _patch[Any]. Ideally we'd be able to add an overload for it so that self is _patch[MagicMock],
164     # but that's impossible with the current type system.
165     def __init__(
166         self: _patch[_T],
167         getter: Callable[[], Any],
168         attribute: str,
169         new: _T,
170         spec: Any | None,
171         create: bool,
172         spec_set: Any | None,
173         autospec: Any | None,
174         new_callable: Any | None,
175         kwargs: Mapping[str, Any],
176     ) -> None: ...
177     def copy(self) -> _patch[_T]: ...
178     @overload
179     def __call__(self, func: _TT) -> _TT: ...
180     @overload
181     def __call__(self, func: Callable[..., _R]) -> Callable[..., _R]: ...
182     def decorate_class(self, klass: _TT) -> _TT: ...
183     def decorate_callable(self, func: Callable[..., _R]) -> Callable[..., _R]: ...
184     def get_original(self) -> tuple[Any, bool]: ...
185     target: Any
186     temp_original: Any
187     is_local: bool
188     def __enter__(self) -> _T: ...
189     def __exit__(self, *exc_info: Any) -> None: ...
190     def start(self) -> _T: ...
191     def stop(self) -> None: ...
192
193 class _patch_dict:
194     in_dict: Any
195     values: Any
196     clear: Any
197     def __init__(self, in_dict: Any, values: Any = ..., clear: Any = ..., **kwargs: Any) -> None: ...
198     def __call__(self, f: Any) -> Any: ...
199     def decorate_class(self, klass: Any) -> Any: ...
200     def __enter__(self) -> Any: ...
201     def __exit__(self, *args: Any) -> Any: ...
202     start: Any
203     stop: Any
204
205 class _patcher:
206     TEST_PREFIX: str
207     dict: Type[_patch_dict]
208     if sys.version_info >= (3, 8):
209         # This overload also covers the case, where new==DEFAULT. In this case, the return type is _patch[Any].
210         # Ideally we'd be able to add an overload for it so that the return type is _patch[MagicMock],
211         # but that's impossible with the current type system.
212         @overload
213         def __call__(  # type: ignore
214             self,
215             target: Any,
216             new: _T,
217             spec: Any | None = ...,
218             create: bool = ...,
219             spec_set: Any | None = ...,
220             autospec: Any | None = ...,
221             new_callable: Any | None = ...,
222             **kwargs: Any,
223         ) -> _patch[_T]: ...
224         @overload
225         def __call__(  # type: ignore
226             self,
227             target: Any,
228             *,
229             spec: Any | None = ...,
230             create: bool = ...,
231             spec_set: Any | None = ...,
232             autospec: Any | None = ...,
233             new_callable: Any | None = ...,
234             **kwargs: Any,
235         ) -> _patch[MagicMock | AsyncMock]: ...
236     else:
237         @overload
238         def __call__(  # type: ignore
239             self,
240             target: Any,
241             new: _T,
242             spec: Any | None = ...,
243             create: bool = ...,
244             spec_set: Any | None = ...,
245             autospec: Any | None = ...,
246             new_callable: Any | None = ...,
247             **kwargs: Any,
248         ) -> _patch[_T]: ...
249         @overload
250         def __call__(  # type: ignore
251             self,
252             target: Any,
253             *,
254             spec: Any | None = ...,
255             create: bool = ...,
256             spec_set: Any | None = ...,
257             autospec: Any | None = ...,
258             new_callable: Any | None = ...,
259             **kwargs: Any,
260         ) -> _patch[MagicMock]: ...
261     if sys.version_info >= (3, 8):
262         @overload
263         def object(  # type: ignore
264             self,
265             target: Any,
266             attribute: str,
267             new: _T,
268             spec: Any | None = ...,
269             create: bool = ...,
270             spec_set: Any | None = ...,
271             autospec: Any | None = ...,
272             new_callable: Any | None = ...,
273             **kwargs: Any,
274         ) -> _patch[_T]: ...
275         @overload
276         def object(  # type: ignore
277             self,
278             target: Any,
279             attribute: str,
280             *,
281             spec: Any | None = ...,
282             create: bool = ...,
283             spec_set: Any | None = ...,
284             autospec: Any | None = ...,
285             new_callable: Any | None = ...,
286             **kwargs: Any,
287         ) -> _patch[MagicMock | AsyncMock]: ...
288     else:
289         @overload
290         def object(  # type: ignore
291             self,
292             target: Any,
293             attribute: str,
294             new: _T,
295             spec: Any | None = ...,
296             create: bool = ...,
297             spec_set: Any | None = ...,
298             autospec: Any | None = ...,
299             new_callable: Any | None = ...,
300             **kwargs: Any,
301         ) -> _patch[_T]: ...
302         @overload
303         def object(  # type: ignore
304             self,
305             target: Any,
306             attribute: str,
307             *,
308             spec: Any | None = ...,
309             create: bool = ...,
310             spec_set: Any | None = ...,
311             autospec: Any | None = ...,
312             new_callable: Any | None = ...,
313             **kwargs: Any,
314         ) -> _patch[MagicMock]: ...
315     def multiple(
316         self,
317         target: Any,
318         spec: Any | None = ...,
319         create: bool = ...,
320         spec_set: Any | None = ...,
321         autospec: Any | None = ...,
322         new_callable: Any | None = ...,
323         **kwargs: Any,
324     ) -> _patch[Any]: ...
325     def stopall(self) -> None: ...
326
327 patch: _patcher
328
329 class MagicMixin:
330     def __init__(self, *args: Any, **kw: Any) -> None: ...
331
332 class NonCallableMagicMock(MagicMixin, NonCallableMock):
333     def mock_add_spec(self, spec: Any, spec_set: bool = ...) -> None: ...
334
335 class MagicMock(MagicMixin, Mock):
336     def mock_add_spec(self, spec: Any, spec_set: bool = ...) -> None: ...
337
338 if sys.version_info >= (3, 8):
339     class AsyncMockMixin(Base):
340         def __init__(self, *args: Any, **kwargs: Any) -> None: ...
341         async def _execute_mock_call(self, *args: Any, **kwargs: Any) -> Any: ...
342         def assert_awaited(self) -> None: ...
343         def assert_awaited_once(self) -> None: ...
344         def assert_awaited_with(self, *args: Any, **kwargs: Any) -> None: ...
345         def assert_awaited_once_with(self, *args: Any, **kwargs: Any) -> None: ...
346         def assert_any_await(self, *args: Any, **kwargs: Any) -> None: ...
347         def assert_has_awaits(self, calls: Iterable[_Call], any_order: bool = ...) -> None: ...
348         def assert_not_awaited(self) -> None: ...
349         def reset_mock(self, *args: Any, **kwargs: Any) -> None: ...
350         await_count: int
351         await_args: _Call | None
352         await_args_list: _CallList
353     class AsyncMagicMixin(MagicMixin):
354         def __init__(self, *args: Any, **kw: Any) -> None: ...
355     class AsyncMock(AsyncMockMixin, AsyncMagicMixin, Mock): ...
356
357 class MagicProxy:
358     name: Any
359     parent: Any
360     def __init__(self, name: Any, parent: Any) -> None: ...
361     def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
362     def create_mock(self) -> Any: ...
363     def __get__(self, obj: Any, _type: Any | None = ...) -> Any: ...
364
365 class _ANY:
366     def __eq__(self, other: Any) -> bool: ...
367     def __ne__(self, other: Any) -> bool: ...
368
369 ANY: Any
370
371 def create_autospec(
372     spec: Any, spec_set: Any = ..., instance: Any = ..., _parent: Any | None = ..., _name: Any | None = ..., **kwargs: Any
373 ) -> Any: ...
374
375 class _SpecState:
376     spec: Any
377     ids: Any
378     spec_set: Any
379     parent: Any
380     instance: Any
381     name: Any
382     def __init__(
383         self,
384         spec: Any,
385         spec_set: Any = ...,
386         parent: Any | None = ...,
387         name: Any | None = ...,
388         ids: Any | None = ...,
389         instance: Any = ...,
390     ) -> None: ...
391
392 def mock_open(mock: Any | None = ..., read_data: Any = ...) -> Any: ...
393
394 PropertyMock = Any
395
396 if sys.version_info >= (3, 7):
397     def seal(mock: Any) -> None: ...