unittest.TestCase.assertIsInstance()

assertIsInstance(obj, cls, msg=None) assertNotIsInstance(obj, cls, msg=None) Test that obj is (or is not) an instance of cls (which can be a class or a tuple of classes, as supported by isinstance()). To check for the exact type, use assertIs(type(obj), cls). New in version 3.2.

unittest.TestCase.assertIs()

assertIs(first, second, msg=None) assertIsNot(first, second, msg=None) Test that first and second evaluate (or don’t evaluate) to the same object. New in version 3.1.

unittest.TestCase.assertIn()

assertIn(first, second, msg=None) assertNotIn(first, second, msg=None) Test that first is (or is not) in second. New in version 3.1.

unittest.TestCase.assertGreaterEqual()

assertGreaterEqual(first, second, msg=None) assertLess(first, second, msg=None) assertLessEqual(first, second, msg=None) Test that first is respectively >, >=, < or <= than second depending on the method name. If not, the test will fail: >>> self.assertGreaterEqual(3, 4) AssertionError: "3" unexpectedly not greater than or equal to "4" New in version 3.1.

unittest.TestCase.assertGreater()

assertGreater(first, second, msg=None) assertGreaterEqual(first, second, msg=None) assertLess(first, second, msg=None) assertLessEqual(first, second, msg=None) Test that first is respectively >, >=, < or <= than second depending on the method name. If not, the test will fail: >>> self.assertGreaterEqual(3, 4) AssertionError: "3" unexpectedly not greater than or equal to "4" New in version 3.1.

unittest.TestCase.assertFalse()

assertFalse(expr, msg=None) Test that expr is true (or false). Note that this is equivalent to bool(expr) is True and not to expr is True (use assertIs(expr, True) for the latter). This method should also be avoided when more specific methods are available (e.g. assertEqual(a, b) instead of assertTrue(a == b)), because they provide a better error message in case of failure.

unittest.TestCase.assertEqual()

assertEqual(first, second, msg=None) Test that first and second are equal. If the values do not compare equal, the test will fail. In addition, if first and second are the exact same type and one of list, tuple, dict, set, frozenset or str or any type that a subclass registers with addTypeEqualityFunc() the type-specific equality function will be called in order to generate a more useful default error message (see also the list of type-specific methods). Changed in version 3.1: Added the au

unittest.TestCase.assertDictEqual()

assertDictEqual(first, second, msg=None) Test that two dictionaries are equal. If not, an error message is constructed that shows the differences in the dictionaries. This method will be used by default to compare dictionaries in calls to assertEqual(). New in version 3.1.

unittest.TestCase.assertCountEqual()

assertCountEqual(first, second, msg=None) Test that sequence first contains the same elements as second, regardless of their order. When they don’t, an error message listing the differences between the sequences will be generated. Duplicate elements are not ignored when comparing first and second. It verifies whether each element has the same count in both sequences. Equivalent to: assertEqual(Counter(list(first)), Counter(list(second))) but works with sequences of unhashable objects as well

unittest.TestCase.assertAlmostEqual()

assertAlmostEqual(first, second, places=7, msg=None, delta=None) assertNotAlmostEqual(first, second, places=7, msg=None, delta=None) Test that first and second are approximately (or not approximately) equal by computing the difference, rounding to the given number of decimal places (default 7), and comparing to zero. Note that these methods round the values to the given number of decimal places (i.e. like the round() function) and not significant digits. If delta is supplied instead of places