-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Open
Labels
pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedstdlibPython modules in the Lib dirPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
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
Metadata
Metadata
Assignees
Labels
pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedstdlibPython modules in the Lib dirPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
Status
Todo