Fix mock patch.dict stub and add mock stub (#2173)

The dict stub was referring to an instance, not the type, leading to
__call__ being considered when using as a decorator, rather than
__init__.

mock is a backport of the stdlib module and should be defined the same.
This commit is contained in:
Robert Collins
2018-06-01 16:45:54 +12:00
committed by Jelle Zijlstra
parent a3031adb46
commit 98badb6eff
3 changed files with 184 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
# Stubs for unittest.mock
import sys
from typing import Any, Optional
from typing import Any, Optional, Type
if sys.version_info >= (3, 3):
FILTER_DIR = ... # type: Any
@@ -111,7 +111,7 @@ if sys.version_info >= (3, 3):
class _patcher:
TEST_PREFIX = ... # type: str
dict = ... # type: _patch_dict
dict = ... # type: Type[_patch_dict]
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: ...
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: ...
def multiple(self, target: Any, spec: Optional[Any] = ..., create: bool = ..., spec_set: Optional[Any] = ..., autospec: Optional[Any] = ..., new_callable: Optional[Any] = ..., **kwargs: Any) -> Any: ...