This can be done automatically using walrus operator (python 3.8+) :
assert (x:=getProbability(2, 3, 2, 1)) == 2/3, "wrong value = "+str(x)