diff options
author | Michael Foord <michael@voidspace.org.uk> | 2012-03-28 15:25:51 +0100 |
---|---|---|
committer | Michael Foord <michael@voidspace.org.uk> | 2012-03-28 15:25:51 +0100 |
commit | 80176401151eaf67c77ac81929af618f69461d0d (patch) | |
tree | ecf383c593cf23b46da206db0cca34df8eaf530d | |
parent | 2a2b0dd94deec0c508b88aa42ca7de8ceeaa47d2 (diff) | |
download | mock-80176401151eaf67c77ac81929af618f69461d0d.tar.gz |
Add example to patch documentation
-rw-r--r-- | docs/patch.txt | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/docs/patch.txt b/docs/patch.txt index e166459..e86899c 100644 --- a/docs/patch.txt +++ b/docs/patch.txt @@ -108,6 +108,17 @@ patch `patch.dict(...)`, `patch.multiple(...)` and `patch.object(...)` are available for alternate use-cases. +`patch` as function decorator: + +.. doctest:: + + >>> @patch('__main__.SomeClass') + ... def function(mock_class): + ... print mock_class is SomeClass + ... + >>> function() + True + Patching a class replaces the class with a `MagicMock` *instance*. If the class is instantiated in the code under test then it will be the |