MCPcopy Index your code
hub / github.com/RustPython/RustPython / _patch_dict

Method _patch_dict

Lib/unittest/mock.py:1934–1959  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1932
1933
1934 def _patch_dict(self):
1935 values = self.values
1936 if isinstance(self.in_dict, str):
1937 self.in_dict = pkgutil.resolve_name(self.in_dict)
1938 in_dict = self.in_dict
1939 clear = self.clear
1940
1941 try:
1942 original = in_dict.copy()
1943 except AttributeError:
1944 # dict like object with no copy method
1945 # must support iteration over keys
1946 original = {}
1947 for key in in_dict:
1948 original[key] = in_dict[key]
1949 self._original = original
1950
1951 if clear:
1952 _clear_dict(in_dict)
1953
1954 try:
1955 in_dict.update(values)
1956 except AttributeError:
1957 # dict like object with no update method
1958 for key in values:
1959 in_dict[key] = values[key]
1960
1961
1962 def _unpatch_dict(self):

Callers 2

_innerMethod · 0.95
__enter__Method · 0.95

Calls 4

isinstanceFunction · 0.85
_clear_dictFunction · 0.85
copyMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected