Q:

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, [])

A:

Based on the comments and confirmation from this question, it seems the best solution is to "consume" the filter.
Because I'm using parameterized testing, the best option is to do this in the function itself and return a plain list.
So my clean_list function is now:
def clean_list(inp):
  return list(filter(None, inp))

and the following unit test now passes:
assert clean_list(['']) == []

