Skip to content

Instantly share code, notes, and snippets.

@pbojinov
Created July 13, 2014 06:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pbojinov/d9f085efdf6da3b8c90c to your computer and use it in GitHub Desktop.
Save pbojinov/d9f085efdf6da3b8c90c to your computer and use it in GitHub Desktop.
python assertions

The TestCase class provides a number of methods to check for and report failures, such as:

Method Checks that
assertEqual(a, b) a == b
assertNotEqual(a, b) a != b
assertTrue(x) bool(x) is True
assertFalse(x) bool(x) is False
assertIs(a, b) a is b
assertIsNot(a, b) a is not b
assertIsNone(x) x is None
assertIsNotNone(x) x is not None
assertIn(a, b) a in b
assertNotIn(a, b) a not in b
assertIsInstance(a, b) isinstance(a, b)
assertNotIsInstance(a, b) not isinstance(a, b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment