If you want multiple conditions in Python to assert and want to do more than one comparison then compare tuples. Or simply write out multiple assertions.
Python asserts multiple conditions
Simple example code.
return x + 1
return y - 1
# some expensive calculation
a = foo(10)
# another expensive calculation
b = bar(10)
assert (a, b) == (10, 9)
Simply write out 3 assertions with the inputs and expected outputs.
def my_func(value): return False if value >= 0 else True def test_my_func(self): assert my_func(1) is False assert my_func(-1) is True assert my_func(0) is True
Do comment if you have any doubts or suggestions on this Python topic.
Note: IDE: PyCharm 2021.3.3 (Community Edition)
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.