i would like to unpack the arguments of a mocked method. I have a mocked subscriber which is called by the code under test and i would like to verify the invocation of the notify() method.
class Subscriber:
def notify(self, event):
pass
I'm using the following snippet to unpack the arguments and verify two invocations:
calls= self.subscriber.notify.call_args_list
event1 = calls[0][0][0]
event2 = calls[1][0][0]
assert_that(event1, instance_of(CreatedEvent))
assert_that(event1.file.name, equal_to("foo.txt"))
But the two lines to unpack the events are very clumsy and far away from readable code. Does somebody know a better approach to unpack the arguments?
Thanks a lot!