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

Method attach_mock

Lib/unittest/mock.py:509–521  ·  view source on GitHub ↗

Attach a mock as an attribute of this one, replacing its name and parent. Calls to the attached mock will be recorded in the `method_calls` and `mock_calls` attributes of this one.

(self, mock, attribute)

Source from the content-addressed store, hash-verified

507
508
509 def attach_mock(self, mock, attribute):
510 """
511 Attach a mock as an attribute of this one, replacing its name and
512 parent. Calls to the attached mock will be recorded in the
513 `method_calls` and `mock_calls` attributes of this one."""
514 inner_mock = _extract_mock(mock)
515
516 inner_mock._mock_parent = None
517 inner_mock._mock_new_parent = None
518 inner_mock._mock_name = ''
519 inner_mock._mock_new_name = None
520
521 setattr(self, attribute, mock)
522
523
524 def mock_add_spec(self, spec, spec_set=False):

Calls 2

_extract_mockFunction · 0.85
setattrFunction · 0.85