pytest_httpx_recorder
Recorder feature based on pytest_httpx, like recorder feature in responses
Installation
pip install pytest_httpx_recorder
For more information about installation, you can refer to Installation.
Record the Requests
import httpx
from pytest_httpx_recorder.recorder import ResRecorder
if __name__ == '__main__':
recorder = ResRecorder()
with recorder.record():
client = httpx.Client(follow_redirects=True)
client.get('https://danbooru.donmai.us/artists/167715.json')
client.head(
'https://cdn.donmai.us/original/9b/25/__akisato_konoha_uehara_meiko_shimoda_kaori_yamada_touya_rokuta_mamoru_and_4_more_comic_party_and_1_more__9b257058ee0866d554d01e9036ecb3b6.jpg')
# save to directory 'test_danbooru_simple'
recorder.to_resset().save('test_danbooru_simple')
Replay in Pytest
import httpx
import pytest
from pytest_httpx_recorder.recorder import ResSet
@pytest.fixture
def replay_from_test_danbooru_simple(httpx_mock):
resset = ResSet.load('test_danbooru_simple')
with resset.mock_context(httpx_mock):
yield
def test_replay(replay_from_test_danbooru_simple):
client = httpx.Client(follow_redirects=True)
resp = client.get('https://danbooru.donmai.us/artists/167715.json')
resp.raise_for_status()
resp = client.head(
'https://cdn.donmai.us/original/9b/25/__akisato_konoha_uehara_meiko_shimoda_kaori_yamada_touya_rokuta_mamoru_and_4_more_comic_party_and_1_more__9b257058ee0866d554d01e9036ecb3b6.jpg')
resp.raise_for_status()
Release files for pytest-httpx-recorder 0.0.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 | |
|---|---|---|---|
| pytest_httpx_recorder-0.0.1.tar.gz | 13.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytest_httpx_recorder-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.0 kB
Release files / pytest_httpx_recorder-0.0.1.tar.gz
| Download URL | pytest_httpx_recorder-0.0.1.tar.gz |
|---|---|
| Size | 13.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3d491135b1b323ad1238416ab93617cf9c9e8782275c400a6f3b036f20d37545
|
|
BLAKE2b-256 checksum How to use checksums |
d66fb46552db25809cdfca1ecb1c406646aa2c8de3158b458db7cc370fdc9989
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Release files / pytest_httpx_recorder-0.0.1-py3-none-any.whl
| Download URL | pytest_httpx_recorder-0.0.1-py3-none-any.whl |
|---|---|
| Size | 12.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d8b74ba86359a892d4acf0f79f31096bace65546b7f5107c3bc20dfb1022129d
|
|
BLAKE2b-256 checksum How to use checksums |
917fccadf9daa6bc17a5459181c2fda4c39a2d8d63b7cb9004eddfcc3198c9fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|