Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Match mock.patch decorator with appropriate param
mock.patch and mock.patch.object can be used as decorators for mocking within the scope of the function they decorate. When there are multiple decorators it is important the function parameters relate to the corresponding patch objects i.e. that the parameter order matches the decorator order. It is easiest to explain this with an example: @mock.patch.object(Foo, 'bar') @mock.patch.object(SomeClass, 'some_method', some_function) @mock.patch.object(AClass, 'a_method') def test_some_stuff(self, mock_a_method, mock_bar): pass So the decorator closest to the function definition must correspond to the first (left-most) patch parameter. Note, if the decorator is given a third argument, the kwarg new, then the decorated function is not passed an extra argument by that decorator. Change-Id: I035d71cb3b81f0c8bfd83ed81d8426cb0df31c90
- Loading branch information