I recently ran into the situation where I wanted to test something that was similar to this function:
Now, on the internet you can read plenty of text that says "you can't mock a local variable". While technically correct, this doesn't help a person who is trying to make assertions about the local instance of a mocked class.
Here is how to get the local instance of the mocked class: mock_session.return_value