Open
Description
Bug report
Would like to set name attribute of a mocked object directly when creating Mock() object.
Currently, the workaround is to do:
from unittest.mock import Mock
obj = Mock(x=1, y="val")
obj.name = "name"
instead of directly assigning the attribute in the constructor.
Has been mentioned in the Stack Overflow community before in https://stackoverflow.com/questions/62552148/how-to-mock-name-attribute-with-unittest-mock-magicmock-or-mock-classes.
Affected code:
Lines 1236 to 1238 in 4261b6b
A suggestion would be to rename the current name
attribute to mock_name
.
Metadata
Metadata
Assignees
Projects
Status
Todo