Recorder feature based on pytest_httpx, like recorder feature in responses.
Project description
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()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pytest_httpx_recorder-0.0.1.tar.gz
.
File metadata
- Download URL: pytest_httpx_recorder-0.0.1.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d491135b1b323ad1238416ab93617cf9c9e8782275c400a6f3b036f20d37545 |
|
MD5 | da4410655cdf679397e4db176168fd83 |
|
BLAKE2b-256 | d66fb46552db25809cdfca1ecb1c406646aa2c8de3158b458db7cc370fdc9989 |
File details
Details for the file pytest_httpx_recorder-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: pytest_httpx_recorder-0.0.1-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8b74ba86359a892d4acf0f79f31096bace65546b7f5107c3bc20dfb1022129d |
|
MD5 | b6e479890411af06191cbd23e42f976b |
|
BLAKE2b-256 | 917fccadf9daa6bc17a5459181c2fda4c39a2d8d63b7cb9004eddfcc3198c9fb |