you can use `Mock(side_effect=AttributeError)` instead of writing your own function.