allow you to easily mock HTTP responses in your tests
Project description
responses_proxy allow you to easily mock HTTP responses in your tests
Installation
$ pip install responses_proxy
Usage
Check command line arguments:
$ responses-proxy -h
First save some stuff using the proxy mode:
$ responses-proxy --proxy
If your target site use ssl then use:
$ responses-proxy --proxy --use-ssl
The proxy do not support ssl so you need to make http request. But first set the HTTP_PROXY env var:
$ export HTTP_PROXY=http://localhost:3333
Then run some code to make some requests:
python -c "import requests; requests.get('http://bearstech.com')"
This will generate some file in tests/responses/
You can now restart the server without the proxy mode and the client will react the same way without calling the real server.
You can aslo use a RequestsMock in you unit tests:
import responses_proxy import requsests def test_url(): with responses_proxy.RequestsMock(): requests.get('http://bearstech.com') # https will work to. both are registered requests.get('https://bearstech.com')
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
responses_proxy-0.1.2.tar.gz
(11.3 kB
view hashes)
Built Distribution
Close
Hashes for responses_proxy-0.1.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44b0601ceb221f08b8d73b7d79b5bf4c8e8265850579cd706a1cfe0d1419873c |
|
MD5 | c3bba550b7be357499cb95261588912f |
|
BLAKE2b-256 | b2b8f876191466c56061340163635d15d1cc8b050a618838f82cbd394f83c4d5 |