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

Method _mock_set_magics

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

Source from the content-addressed store, hash-verified

2185
2186
2187 def _mock_set_magics(self):
2188 orig_magics = _magics | _async_method_magics
2189 these_magics = orig_magics
2190
2191 if getattr(self, "_mock_methods", None) is not None:
2192 these_magics = orig_magics.intersection(self._mock_methods)
2193 remove_magics = orig_magics - these_magics
2194
2195 for entry in remove_magics:
2196 if entry in type(self).__dict__:
2197 # remove unneeded magic methods
2198 delattr(self, entry)
2199
2200 # don't overwrite existing attributes if called a second time
2201 these_magics = these_magics - set(type(self).__dict__)
2202
2203 _type = type(self)
2204 for entry in these_magics:
2205 setattr(_type, entry, MagicProxy(entry, self))
2206
2207
2208

Callers 3

__init__Method · 0.95
mock_add_specMethod · 0.80
mock_add_specMethod · 0.80

Calls 3

setFunction · 0.85
MagicProxyClass · 0.85
intersectionMethod · 0.45

Tested by

no test coverage detected