I am trying to create MagicMock with mocked name and it seems as not working, but works for other attributes:
from unittest.mock import MagicMock
# Works
assert MagicMock(foo='bar').foo == 'bar'
# Don't work
assert MagicMock(name='bar').name == 'bar'
print(MagicMock(name='bar').name)
<MagicMock name=\'bar.name\' id=\'140031146167376\'>
How to mock name attribute with MagicMock ?