1+ ===========
12pytest-mock
23===========
34
4- This plugin installs a fixture ``mock `` which is a thin-wrapper around the patching API
5+ This plugin installs a ``mock `` fixture which is a thin-wrapper around the patching API
56provided by the excellent `mock <http://pypi.python.org/pypi/mock >`_ package,
67but with the benefit of not having to worry about undoing patches at the end
78of a test:
@@ -16,28 +17,29 @@ of a test:
1617
1718
1819 Usage
19- -----
20+ =====
2021
2122The ``mock `` fixture has the same API as
2223`mock.patch <http://www.voidspace.org.uk/python/mock/patch.html#patch-decorators >`_,
2324supporting the same arguments:
2425
2526.. code-block :: python
2627
27- # all valid calls
28- mock.patch(' os.remove' )
29- mock.patch.object(os, ' listdir' , autospec = True )
30- mocked = mock.patch(' os.remove' )
28+ def test_foo (mock ):
29+ # all valid calls
30+ mock.patch(' os.remove' )
31+ mock.patch.object(os, ' listdir' , autospec = True )
32+ mocked = mock.patch(' os.path.isfile' )
3133
3234 The supported methods are:
3335
3436* ``mock.patch ``: see http://www.voidspace.org.uk/python/mock/patch.html#patch.
35- * ``mock.patch.object ``: see ` http://www.voidspace.org.uk/python/mock/patch.html#patch-object.
36- * ``mock.patch.multiple``: see ` http://www.voidspace.org.uk/python/mock/patch.html#patch-multiple.
37+ * ``mock.patch.object ``: see http://www.voidspace.org.uk/python/mock/patch.html#patch-object.
38+ * ``mock.patch.multiple ``: see http://www.voidspace.org.uk/python/mock/patch.html#patch-multiple.
3739* ``mock.stopall() ``: stops all active patches at this point.
3840
3941Why bother with a plugin?
40- -------------------------
42+ =========================
4143
4244There are a number of different ``patch `` usages in the standard ``mock `` API,
4345but IMHO they don't scale very well when you have a more than one or two
0 commit comments