["python","unit-testing","pytest"]
How can I assert lists equality with pytest

I'm trying to make some unit tests with pytest. I was thinking about doing things like that: actual = b_manager.get_b(complete_set) assert actual is not None assert actual.columns == ['bl', 'direction', 'day'] The first assertion in ok but with the second I have an value error. ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() I assume it is not the right way to assert the equality of two different lists with pytest. How can I assert that the dataframe columns (a list) is equal to the expected one? Thanks
You could do a list comprehension to check equality of all values. If you call all on the list comprehensions result, it will return True if all parameters are equal. actual = ['bl', 'direction', 'day'] expected = ['bl', 'direction', 'day'] assert len(actual) == len(expected) assert all([a == b for a, b in zip(actual, expected)]) print(all([a == b for a, b in zip(actual, expected)])) >>> True