I am using Python 3.6 and requests 2.19.
After initializing the virtual environment and installing the responses library with pip install responses successfully:
Successfully installed cookies-2.2.1 responses-0.9.0
When I try to use it as described in responses git page:
import responses
from src.controllers.user_controller import UserController
class UserControllerTest(TestCase):
@responses.activate
def test_get_address_by_zip_code_returns_address_for_valid_zip_code(self):
responses.add(
responses.GET,
'https://api.postmon.com.br/v1/cep/82200530',
json= {
'country': 'Test',
'city': 'test city',
'street' : 'some street'
},
status=200)
self.user_controller = UserController()
result = self.user_controller.get_address_by_zip_code(82200530)
self.assertIsNotNone(result)
It throws an error :
E AttributeError: module 'responses' has no attribute 'activate'
All the other tests in this test class pass. This is the only one that uses responses and the only one that is failing.
Does anybody knows why responses it not working?
I had a responses.py file in my case and was getting same error. I renamed same file post which this issue resolved