jeudi 28 juillet 2016

How to mock object attributes and complex fields and methods?

I have a following function which needs to be unit tested.

def read_all_fields(all_fields_sheet):
    entries = []

    for row_index in xrange(2, all_fields_sheet.nrows):
        d = {'size' : all_fields_sheet.cell(row_index,0).value,\
             'type' : all_fields_sheet.cell(row_index,1).value,\
             'hotslide' : all_fields_sheet.cell(row_index,3).value}
        entries.append((all_fields_sheet.cell(row_index,2).value,d))

    return entries

Now, my all_fields_sheet is a sheet returned by xlrd module(Used to read Excel file).

So, basically I need to mock for following attributes nrows cell

How should I go abput it?

Aucun commentaire:

Enregistrer un commentaire