If you’re calling sendmail
with a named parameter subject
then it’s better to check whether the named argument matches what you expect:
args, kwargs = self.myclass.sendmail.call_args
self.assertEqual(kwargs['subject'], "Hello World")
This does assume both implementations of sendmail
have a named parameter called subject
. If that’s not the case you can do the same with a positional parameter:
args, kwargs = self.myclass.sendmail.call_args
self.assertTrue("Hello World" in args)
You can be explicit about the position of the argument (i.e., the first argument or the third argument that’s passed to sendmail
but that depends on the implementation of sendmail
being tested).