Unfortunately, assert is a statement, and the limited lythdas of Pythons do not allow this in them. They also limit things like print .
Here you can use the generator expression.
assert all(x[0] == x[1] for x in zip( [run_function(i) for i in values ], expected_values))
I personally think the following will be more readable
assert all(run_function(i) == j for i,j in zip(inputs, expected_values))
source share