Skip to content

Commit 3ff7f28

Browse files
committed
Minor fixes in README wording
1 parent 8447a7b commit 3ff7f28

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

README.rst

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ of the test:
8989
def test_unix_fs():
9090
with mock.patch('os.remove'):
9191
UnixFS.rm('file')
92-
os.remote.assert_called_once_with('file')
92+
os.remove.assert_called_once_with('file')
9393
9494
with mock.patch('os.listdir'):
9595
assert UnixFS.ls('dir') == expected
@@ -100,8 +100,7 @@ of the test:
100100
# ...
101101
102102
103-
One can use ``patch`` as a decorator to improve the flow of the test, but now the
104-
test functions must receive the mock objects:
103+
One can use ``patch`` as a decorator to improve the flow of the test:
105104

106105
.. code-block:: python
107106
@@ -110,14 +109,19 @@ test functions must receive the mock objects:
110109
@mock.patch('shutil.copy')
111110
def test_unix_fs(mocked_copy, mocked_listdir, mocked_copy):
112111
UnixFS.rm('file')
113-
os.remote.assert_called_once_with('file')
112+
os.remove.assert_called_once_with('file')
114113
115114
assert UnixFS.ls('dir') == expected
116115
# ...
117116
118117
UnixFS.cp('src', 'dst')
119118
# ...
120119
121-
Even when you prefer to access the mocks using the original references. Besides
122-
don't mixing nicely with other fixtures (although it works), you can't
123-
easily undo the mocking if you follow this approach.
120+
But this poses a few disadvantages:
121+
122+
- test functions must receive the mock objects as parameter, even if you don't plan to
123+
access them directly; also, order depends on the order of the decorated ``patch``
124+
functions;
125+
- receiving the mocks as parameters doesn't mix nicely with pytest's approach of
126+
naming fixtures as parameters, or ``pytest.mark.parametrize``;
127+
- you can't easily undo the mocking during the test execution;

0 commit comments

Comments
 (0)