@@ -82,6 +82,8 @@ rules have been defined:
8282 the ` new ` , ` spec ` , ` spec_set ` , ` autospec ` or ` new_callable ` arguments
8383* ` TMS021 ` : checks that ` unittest.mock.patch.object ` is called with any one or
8484 more of the ` new ` , ` spec ` , ` spec_set ` , ` autospec ` or ` new_callable ` arguments
85+ * ` TMS022 ` : checks that ` unittest.mock.patch.multiple ` is called with any one
86+ or more of the ` spec ` , ` spec_set ` , ` autospec ` or ` new_callable ` arguments
8587
8688### Fix TMS010
8789
@@ -153,8 +155,8 @@ def test_foo():
153155 mocked_foo = mock.MagicMock(spec_set = Foo)
154156```
155157
156- For more information about ` mock.MagicMock ` and how to use it, please refer to the
157- official documentation:
158+ For more information about ` mock.MagicMock ` and how to use it, please refer to
159+ the official documentation:
158160https://docs.python.org/3/library/unittest.mock.html#unittest.mock.MagicMock
159161
160162### Fix TMS012
@@ -190,8 +192,8 @@ def test_foo():
190192 mocked_foo = mock.NonCallableMock(spec_set = Foo)
191193```
192194
193- For more information about ` mock.NonCallableMock ` and how to use it, please refer to the
194- official documentation:
195+ For more information about ` mock.NonCallableMock ` and how to use it, please
196+ refer to the official documentation:
195197https://docs.python.org/3/library/unittest.mock.html#unittest.mock.NonCallableMock
196198
197199### Fix TMS013
@@ -233,7 +235,7 @@ https://docs.python.org/3/library/unittest.mock.html#unittest.mock.AsyncMock
233235
234236### Fix TMS020
235237
236- This linting rule is triggered when calling unittest.mock.patch without
238+ This linting rule is triggered when calling ` unittest.mock.patch ` without
237239including one or more of the following arguments: ` new ` , ` spec ` , ` spec_set ` ,
238240` autospec ` , or ` new_callable ` .
239241
@@ -272,13 +274,13 @@ foo_patcher = patch("Foo", autospec=True)
272274
273275For more information about ` mock.patch ` and how to use it, please refer to the
274276official documentation:
275- https://docs.python.org/3/library/unittest.mock.html#patch
277+ https://docs.python.org/3/library/unittest.mock.html#unittest.mock. patch
276278
277279### Fix TMS021
278280
279- This linting rule is triggered when calling unittest.mock.patch.object without
280- including one or more of the following arguments: ` new ` , ` spec ` , ` spec_set ` ,
281- ` autospec ` , or ` new_callable ` .
281+ This linting rule is triggered when calling ` unittest.mock.patch.object `
282+ without including one or more of the following arguments: ` new ` , ` spec ` ,
283+ ` spec_set ` , ` autospec ` , or ` new_callable ` .
282284
283285For example, this code will trigger the rule:
284286
@@ -317,4 +319,47 @@ foo_patcher = patch(Foo, "bar", autospec=True)
317319
318320For more information about ` mock.patch.object ` and how to use it, please refer
319321to the official documentation:
320- https://docs.python.org/3/library/unittest.mock.html#patch
322+ https://docs.python.org/3/library/unittest.mock.html#unittest.mock.patch.object
323+
324+ ### Fix TMS022
325+
326+ This linting rule is triggered when calling ` unittest.mock.patch.multiple `
327+ without including one or more of the following arguments: ` spec ` , ` spec_set ` ,
328+ ` autospec ` , or ` new_callable ` .
329+
330+ For example, this code will trigger the rule:
331+
332+ ``` Python
333+ from unittest import mock
334+
335+ @mock.patch.multiple (" Foo" , FIRST_PATCH = ' bar' , SECOND_PATCH = ' baz' )
336+ def test_foo ():
337+ pass
338+
339+ with mock.patch.object(" Foo" , FIRST_PATCH = ' bar' , SECOND_PATCH = ' baz' ) as mocked_foo:
340+ pass
341+
342+ foo_patcher = patch(" Foo" , FIRST_PATCH = ' bar' , SECOND_PATCH = ' baz' )
343+ ```
344+
345+ To fix this issue, include one or more of the aforementioned arguments when
346+ calling ` mock.patch.multiple ` . For example:
347+
348+ ``` Python
349+ from unittest import mock
350+
351+ from foo import Foo
352+
353+ @mock.patch.multiple (" Foo" , spec = Foo, FIRST_PATCH = ' bar' , SECOND_PATCH = ' baz' )
354+ def test_foo ():
355+ pass
356+
357+ with mock.patch.object(" Foo" , spec_set = Foo, FIRST_PATCH = ' bar' , SECOND_PATCH = ' baz' ) as mocked_foo:
358+ pass
359+
360+ foo_patcher = patch(" Foo" , autospec = True , FIRST_PATCH = ' bar' , SECOND_PATCH = ' baz' )
361+ ```
362+
363+ For more information about ` mock.patch.multiple ` and how to use it, please
364+ refer to the official documentation:
365+ https://docs.python.org/3/library/unittest.mock.html#unittest.mock.patch.multiple
0 commit comments