Skip to content

Commit e6b21b6

Browse files
committed
Fixed formatting in README
1 parent 59d7128 commit e6b21b6

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

README.rst

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
pytest-mock
22
===========
33

4-
Thin-wrapper around the mock package for easier use with py.test.
5-
6-
This plugin provides a fixture named `mock` that has the same patching API
4+
This plugin installs a fixture ``mock`` which is a thin-wrapper around the patching API
75
provided by the excellent `mock <http://pypi.python.org/pypi/mock>`_ package,
86
but with the benefit of not having to worry about undoing patches at the end
9-
of a test::
7+
of a test:
8+
9+
.. code-block:: python
1010
1111
1212
def test_unix_fs(mock):
@@ -18,9 +18,11 @@ of a test::
1818
Usage
1919
-----
2020

21-
The `mock` fixture has the same API as
22-
`mock.patch <http://www.voidspace.org.uk/python/mock/patch.html#patch-decorators>`_,
23-
supporting the same arguments::
21+
The ``mock`` fixture has the same API as
22+
`mock.patch <http://www.voidspace.org.uk/python/mock/patch.html#patch-decorators>`_,
23+
supporting the same arguments:
24+
25+
.. code-block:: python
2426
2527
# all valid calls
2628
mock.patch('os.remove')
@@ -29,20 +31,22 @@ The `mock` fixture has the same API as
2931
3032
The supported methods are:
3133

32-
- `mock.patch`: see http://www.voidspace.org.uk/python/mock/patch.html#patch.
33-
- `mock.patch.object`: see `http://www.voidspace.org.uk/python/mock/patch.html#patch-object.
34-
- `mock.patch.multiple`: see `http://www.voidspace.org.uk/python/mock/patch.html#patch-multiple.
35-
- `mock.stopall()`: stops all active patches at this point.
34+
* ``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.stopall()``: stops all active patches at this point.
3638

3739
Why bother with a plugin?
3840
-------------------------
3941

40-
There are a number of different `patch` usages in the standard `mock` API,
41-
but IMHO they don't scale very well when you have a more than one or two
42-
patches to apply.
42+
There are a number of different ``patch`` usages in the standard ``mock`` API,
43+
but IMHO they don't scale very well when you have a more than one or two
44+
patches to apply.
4345

44-
It may lead to an excessive nesting of `with` statements, breaking the flow
45-
of the test::
46+
It may lead to an excessive nesting of ``with`` statements, breaking the flow
47+
of the test:
48+
49+
.. code-block:: python
4650
4751
import mock
4852
@@ -60,8 +64,10 @@ It may lead to an excessive nesting of `with` statements, breaking the flow
6064
# ...
6165
6266
63-
One can use `patch` as a decorator to improve the flow of the test, but now the
64-
test functions must receive the mock objects::
67+
One can use ``patch`` as a decorator to improve the flow of the test, but now the
68+
test functions must receive the mock objects:
69+
70+
.. code-block:: python
6571
6672
@mock.patch('os.remove')
6773
@mock.patch('os.listdir')

0 commit comments

Comments
 (0)