def patch(fn, attr_or_replacement, replacement=None): """pass""" if replacement is None: replacement = attr_or_replacement return when2(fn, Ellipsis).thenAnswer(replacement) else: obj, name = (fn, attr_or_replacement) theMock = _get_mock(obj, strict=True) return invocation.StubbedInvocation(theMock, name, strict=False)(Ellipsis).thenAnswer(replacement)