PyUnit Assertions
Assertion commands check and validate a given condition’s result, whether True or False.
Some of the most commonly used assertions are as follows in table format:
Assertion | Description |
assertTrue(x) | This method returns True if bool(x) is True |
assertFalse(x) | This method returns True if bool(x) is False |
assertEqual(a, b) | This method returns True if a == b |
assertNotEqual(a,b) | This method returns True if a != b |
assertIn(a,b) | This method returns True if a is in b |
assertNotIn(a,b) | This method returns True if a is not in b |
assertGreater(a,b) | This method returns True if a > b |
assertGreaterEqual(a,b) | This method returns True if a >= b |
assertLess(a,b) | This method returns True if a < b |
assertLessEqual(a,b) | This method returns True if a <= b |
To get the full list use the Eclipse IDE.
Assert statements mark the test as pass or fail depending on the expected conditions and actual results during the test run.
Failed assertions will throw : AssertionError