Skip to content

paivett/requests-curl

Repository files navigation

requests-curl

Tests

This package provides an adapter to use PyCURL as backend for the requests library.

Requirements

To be able to use this adapter, you need PyCURL, and, of course, requests.

Installation

Clone this project, and then, in the desired virtualenvironment, just run

python setup.py install

PyPI integration comming soon.

Usage

Simply import the adapter and mount it

import requests

from requests_curl import CURLAdapter

session = requests.Session()

session.mount("http://", CURLAdapter())
session.mount("https://", CURLAdapter())

response = session.get("https://google.com")

print(response.status_code)

Running tests

Tests are implemented with pytest. To run tests, just do

pytest tests/

End-to-end tests

These tests are meant to test that the whole communication with a real server works. For these tests, we use docker compose and the server is based on httpbin.

To run these tests, you will need Docker Compose. First, build the test runner image

docker-compose -f docker-compose.tests.yml build

Then run tests

docker-compose -f docker-compose.tests.yml up --exit-code-from e2e_tests_runner

Release history

  • 0.1
    • Initial release

Troubleshooting

PyCURL

If you are having trouble installing PyCURL, check this: https://stackoverflow.com/a/51959349.

Also, if you get this error while running tests or using pycurl

    import pycurl
E   ImportError: pycurl: libcurl link-time ssl backends (secure-transport, openssl) do not include compile-time ssl backend (none/other)

On MacOS these steps worked for me: