Reference - http://docs.python.org/library/unittest.html#assert-methods
assertEqual(a, b) # checks that a == b
assertIs(a, b) # checks that a is b <---- whatever that means????
Using assertEqual
the two objects need not be of the same type, they merely need to be the same value. In comparison, using assertIs
the two objects need to be the same object.
assertEqual
tests for equality like the ==
operator:
The operators <, >, ==, >=, <=, and != compare the values of two objects. The objects need not have the same type. If both are numbers, they are converted to a common type. Otherwise, objects of different types always compare unequal, and are ordered consistently but arbitrarily.
assertIs
test for object identity same as the is
and is not
operators:
The operators is and is not test for object identity: x is y is true if and only if x and y are the same object. x is not y yields the inverse truth value.
The above quotes both come from the Python documentation section 5.9 Comparisons.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With