jeudi 28 juillet 2016

How do I unit test a filter?

I'm using a filter to remove empty values from a list:

def clean_list(inp):
  return filter(None, inp)

How do I unit-test this piece of code?

All of the following fail because the return of clean_list is a filter object and it doesn't match any of these:

assert clean_list(['']) == []
assert clean_list(['']) == ['']
assert clean_list(['']) == filter(None, [''])
assert clean_list(['']) == filter(None, [])

Aucun commentaire:

Enregistrer un commentaire