Created
June 15, 2012 20:15
-
-
Save Rafe/2938499 to your computer and use it in GitHub Desktop.
python unittest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 2.7 | |
assertIsNot(a, b) #a is not b 2.7 | |
assertIsNone(x) #x is None 2.7 | |
assertIsNotNone(x) #x is not None 2.7 | |
assertIn(a, b) #a in b 2.7 | |
assertNotIn(a, b) #a not in b 2.7 | |
assertIsInstance(a, b) #isinstance(a, b) 2.7 | |
assertNotIsInstance(a, b)# not isinstance(a, b) 2.7 | |
#Mock: | |
>>> from mock import MagicMock | |
>>> a = MagicMock() | |
>>> a.test.return_value = 123 | |
>>> a.test() | |
123 | |
>>> a.test.called | |
True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment