Bug report
Bug description:
As in the title. The following code seems to disregard the partial and proceed to call the wrapped function right away (instead of calling the wrapping partial object).
from functools import partial
from unittest.mock import patch
def wrapped():
"""an exemplary response from `some.directory.module.my_function` function"""
return [
{
"some_key": "some_value",
}]
def test_some_func():
with patch(
"some.directory.module.my_function", new_callable=partial(wrapped)
):
# calls `my_function` internally
some.directory.module.another_function()
Running the above will produce: TypeError: 'list' object is not callable.
Acc. to the docs an object passed as new_callable argument should be called by patch to create a new dummy object replacing the target (some.directory.module.my_function). However it seems that instead of partial being called and returning a wrapped function, a wrapped function itself is called returning the list.
CPython versions tested on:
3.11
Operating systems tested on:
macOS
Bug report
Bug description:
As in the title. The following code seems to disregard the partial and proceed to call the wrapped function right away (instead of calling the wrapping partial object).
Running the above will produce:
TypeError: 'list' object is not callable.Acc. to the docs an object passed as new_callable argument should be called by
patchto create a new dummy object replacing the target (some.directory.module.my_function). However it seems that instead of partial being called and returning a wrapped function, a wrapped function itself is called returning the list.CPython versions tested on:
3.11
Operating systems tested on:
macOS