python - How to test for the second parameter of a mocked method? -



python - How to test for the second parameter of a mocked method? -

i trying mock sendemails() method , test if sec parameter called "test@test.com" email address.

@mock.patch('apps.dbank.management.commands.optin_invites.optinbase.sendemails') def test_x_send_emails(self, send_emails_mock): oi = optininvitesx() oi.compute(true, "test@test.com") self.asserttrue(send_emails_mock.assert_called_with(???, test_email_address="test@test.com"))

i utilise assert_called_with don't care first parameter test case. there way take first parameter?

i couldn't figure out how when attempting same thing.

here hacky workaround:

from mock import magicmock class yesman(object): def __eq__(self, other): homecoming true = yesman() mock = magicmock() mock(x=123, y=456) mock.assert_called_once_with(x=anything, y=456)

an alternative @ attribute

>>> mock.call_args call(y=456, x=123)

and build assertions on object.

python unit-testing python-mock

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -