Requests-testing
A utility library for mocking out the requests Python library.
Starting with requests-testing
Here is a simple example:
import requests
import requests_testing
@requests_testing.activate
def example():
requests_testing.add(request={'url': 'http://example.com'}, response={'body': 'ok'})
resp = requests.get('http://example.com')
assert resp.text == 'ok'
assert len(requests_testing.calls) == 1
assert requests_testing.calls[0].request.url == 'http://example.com/'
If your attempts to fetch a url which doesn’t hit a match, ConnectionError will raise:
import requests
import requests_testing
from requests.exceptions import ConnectionError
@responses.activate
def test_error():
with pytest.raises(ConnectionError):
requests.get('http://example.com')
Metadata
Release files for requests-testing 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| requests_testing-0.2.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for requests_testing-0.2.0-py2.py3-none-any.whl |
Release files / requests_testing-0.2.0-py2.py3-none-any.whl
| Download URL | requests_testing-0.2.0-py2.py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
99045f6505469ad84ffc75fbd74bfa690e8aebca45b3c98a79d2cde7d3b481dc
|
|
BLAKE2b-256 checksum How to use checksums |
558a3bf69679e02faa7ef03d3072251dc0f6c6c6de44602bed9a41a1173cbe29
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for requests-testing 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.