I'm using MagicMock with Python 2.7 to mock objects. One of the classes that I'm mocking has properties, one of which can raise a TypeError in some cases.
I would like to mock that behavior, but I can't figure out how:
del my_mock.my_propertywill cause anAttributeErrorifmy_propertyis accessed, but I need aTypeError.my_mock.my_property = MagicMock(side_effect=TypeError)causes aTypeErrorwhenmy_propertyis called, but not when it's merely accessed.
How would I do that?