Reputation: 5428
When I'm trying to run this test:
from unittest import mock
@mock.patch('requests.get', side_effect=mocked_requests_get)
@mock.patch('requests.post', side_effect=mocked_requests_post)
def test_zeros(self, response):
self.assertEqual(0, 0)
it says TypeError: test_zeros() takes 2 positional arguments but 3 were given
. So, how can I mock two different methods (I need requests.get
and requests.post
) in one test?
Upvotes: 0
Views: 214
Reputation: 599788
The mocks defined in decorators are passed to the decorated function. I don't know what response
is supposed to be but you need to accept an argument for the get and post objects.
@mock.patch('requests.get', side_effect=mocked_requests_get)
@mock.patch('requests.post', side_effect=mocked_requests_post)
def test_zeros(self, post_mock, get_mock):
self.assertEqual(0, 0)
Upvotes: 1