DEV Community

Gabor Szabo
Gabor Szabo

Posted on • Originally published at code-maven.com

2

Development environment for the Python requests package

To make it easier to start to contribute to an open source project, one needs to know how to set up a development environment locally and how to run the tests of the project locally.

As I did not find this information for the requests Python library I am now trying to describe it myself.

Clone the repository

This part can be found in the README of the GitHub repository.

You need to have Python installed and some libraries. You can run it natively on your operating system in a virtual environment or you can run it in a Docker container.

Start Docker

docker run -it --rm --workdir /opt -v$(pwd):/opt python:3.11 bash
Enter fullscreen mode Exit fullscreen mode
make init
Enter fullscreen mode Exit fullscreen mode

That basically runs

pip install -r requirements-dev.txt
Enter fullscreen mode Exit fullscreen mode

To run the tests you could type

make test
Enter fullscreen mode Exit fullscreen mode

but it needs tox so first you'll have to run

pip install tox
Enter fullscreen mode Exit fullscreen mode

then you can run

make test
Enter fullscreen mode Exit fullscreen mode

That will actually run

tox -p
Enter fullscreen mode Exit fullscreen mode

I also like to be able to run the tests and generate code-coverage report and run the tests in random order.

pip install pytest-random-order pytest-coverage

pytest -svv --random-order --cov-config .coveragerc --cov=requests --cov-report html --cov-report term --cov-branch
Enter fullscreen mode Exit fullscreen mode

Virtualenv

virtualenv -p python3 venv
. venv/bin/activate
Enter fullscreen mode Exit fullscreen mode
pip install pytest-coverage
pytest --cov-config .coveragerc --verbose --cov-report term --cov-report xml --cov-report html --cov=requests --cov-branch tests
Enter fullscreen mode Exit fullscreen mode

Adding this to the project

Ideally this and more information about contribution would be included either in the README file or in the CONTRIBUTIONS file of the project. So I opened an issue asking if they would be interested in it.

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay