lundi 29 juin 2015

Python unit test mock, get mocked function's input arguments

I want a unit test to assert that a variable action within a function is getting set to its expected value, the only time this variable is used is when it is passed in a call to a library.

Class Monolith(object):
    def foo(self, raw_event):
        action =  # ... Parse Event
        # Middle of function
        lib.event.Event(METADATA, action)
        # Continue on to use the build event.

My thought was that I could mock lib.event.Event, and get its input arguments and assert they are of specific value.

>Is this not how mocks work? The mock documentation frustrates me with its inconsistency, half-examples, and plethora of examples that are not related to what I want to do.

Aucun commentaire:

Enregistrer un commentaire