diff options
author | fuzzyman <devnull@localhost> | 2010-06-22 14:12:48 +0000 |
---|---|---|
committer | fuzzyman <devnull@localhost> | 2010-06-22 14:12:48 +0000 |
commit | 96a70788fbea6c0941dbd6fcb0cab0cd4ae6a5e8 (patch) | |
tree | 4f65cad4a3dc2f181952d244afbb12cd64b1b0af /docs/magicmock.txt | |
parent | 77176894d2ba37180352770b4ce566b9f59364e7 (diff) | |
download | mock-96a70788fbea6c0941dbd6fcb0cab0cd4ae6a5e8.tar.gz |
Docs improvements
Diffstat (limited to 'docs/magicmock.txt')
-rw-r--r-- | docs/magicmock.txt | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/docs/magicmock.txt b/docs/magicmock.txt index bc7ddd3..bc29e56 100644 --- a/docs/magicmock.txt +++ b/docs/magicmock.txt @@ -106,6 +106,43 @@ and use them in the usual way: 'result' By default many of the protocol methods are required to return objects of a +specific type. These methods are preconfigured with a default return value, so +that they can be used without you having to do anything if you aren't interested +in the return value. You can still *set* the return value manually if you want +to change the default. + +Methods and their defaults: + +* ``__int__`` : 0 +* ``__contains__`` : False +* ``__len__`` :0 +* ``__iter__`` : iter([]) +* ``__exit__`` : False +* ``__complex__`` : 0j +* ``__float__`` : 0.0 +* ``__bool__`` : True +* ``__nonzero__`` : True +* ``__oct__`` : '0' +* ``__hex__`` : '0x0' +* ``__long__`` : long(0) +* ``__index__`` : 0 +* ``__hash__`` : default hash for the mock +* ``__repr__`` : default repr for the mock +* ``__str__`` : default str for the mock +* ``__unicode__`` : default unicode for the mock + +For example: + +.. doctest:: + + >>> from mock import MagicMock + >>> mock = MagicMock() + >>> int(mock) + 0 + >>> len(mock) + 0 + >>> hex(mock) + '0x0' ``MagicMock`` has all of the supported magic methods configured except for some |