This package provides a plugin for pytest framework for capturing and mocking connection requests during the test run.
Installation
$ pip install pytest-remote-response
or
$ git clone https://github.com/devanshshukla99/pytest-remote-response
$ cd pytest-remote-response
$ pip install .
The plugin will register automatically with pytest framework and will be ready to use.
Usage
Pytest plugin
The plugin works by using interceptors of different libraries which can be checked by response.available() method; these interceptors have to be applied for each pytest run using --remote={INTERCEPTOR}.
$ pytest --remote="urllib_quick|requests_quick|aiohttp_quick"
Handling requests:
- Prevent remote requests:
all requests are allowed by default; one can disable them using –remote-blocked flag.
$ pytest --remote={INTERCEPTORS} --remote-blocked
- Capture remote requests:
the requests can be captured in a json file using --remote-capture arg.
$ pytest --remote={INTERCEPTORS} --remote-capture
- Mock remote requests:
the requests can be mocked using --remote-response flag.
NOTE: Due to certain limitations, it is advised to not use this plugin in an offline environment.
$ pytest --remote={INTERCEPTORS} --remote-response
Standalone package
The tools implemented in this package can be easily ported to any other application, with mimial config required.
Configuration:
from pytest_response import response
response.setup_database({DUMP FILE})
response.post({INTERCEPTOR})
...
response.unpost()
Testing
Use tox to make sure the plugin is working:
$ git clone https://github.com/devanshshukla99/pytest-remote-response
$ cd pytest-remote-response
$ tox -e py38
See tox for more info.
Licence
This plugin is licenced under a 3-clause BSD style licence - see the LICENCE file.
Metadata
Release files for pytest-remote-response 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pytest-remote-response-0.2.1.tar.gz | 16.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytest_remote_response-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 32.6 kB
Release files / pytest-remote-response-0.2.1.tar.gz
| Download URL | pytest-remote-response-0.2.1.tar.gz |
|---|---|
| Size | 16.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
15b3952dde89062cc445f2c2961bbcdf2224609bf402c48b4ccaba54fe24f07f
|
|
BLAKE2b-256 checksum How to use checksums |
c1854220ae478bf0988677575039d51e33eccf9a30cd0ed7375c93eb9ab3f6fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10
|
Release files / pytest_remote_response-0.2.1-py3-none-any.whl
| Download URL | pytest_remote_response-0.2.1-py3-none-any.whl |
|---|---|
| Size | 16.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ca6c1a3a8f5bedff832dc10f4db42d6b6d33828a0922fb274951885e1125146b
|
|
BLAKE2b-256 checksum How to use checksums |
1084aa0fc1520c216e7e03fdc749e65c448cde2aee32afc2370a7dcf57ea9a9a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10
|
Security for pytest-remote-response 0.2.1
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.