MCPcopy Index your code
hub / github.com/python/cpython / _patch_dict

Method _patch_dict

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

Source from the content-addressed store, hash-verified

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

Callers 2

_innerMethod · 0.95
__enter__Method · 0.95

Calls 3

_clear_dictFunction · 0.85
copyMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected