I'm using mox to stub out an email-sending function in my code. I want to verify that the function is called N times, with a certain set of params each time.
Mox is raising ValueError("There must be at least one expected method") as if the function calls that I've stubbed out are not happening, but they actually seem to be happening.
Watching my logs, I can see the functions being called and see all the log messages / updates in my DB that tell me the code being tested is in fact working. I also have 14 other unit tests verifying that, so I'm confident this is a problem with the test rather than the underlying code.
Here is my test:
class MyTestSuite(mox.MoxTestBase):
def test_my_send_function(self):
self.mox.StubOutWithMock(module_path, "my_send_function")
for state in SEQUENCE: # defined elsewhere, assume 5 states in sequence
module_path.my_send_function(to_email_address, subject, IgnoreArg())
self.mox.ReplayAll()
module_path.my_send_function_parent() # loops over the 5 states in SEQUENCE and calls my_send_function()
# Verify() and UnsetStubs() are done automatically because I subclasses MoxTestBase
Why is mox saying the calls never happened when they are? I could not find anything about this in the mox docs or elsewhere here on SO.