I am having trouble mocking the function. Even if I mock, it still sends an email.
Propagate a boolean "mock_if_true" and at the very last moment do not send the email. This is simple/stupid and OK as long as you do not have many such booleans.
OR: override the python class method (if you have one) to mock it
OR: consider separating the code building the email object from the code sending it. So you may easily test if the object is properly built.
How to unit test mock a mail sending function without sending mail python? I am using unittest.mock function