# pytest_httpx_recorder
[](https://pypi.org/project/pytest_httpx_recorder/)



[](https://github.com/narugo1992/pytest_httpx_recorder/actions?query=workflow%3A%22Code+Test%22)
[](https://github.com/narugo1992/pytest_httpx_recorder/actions?query=workflow%3A%22Package+Release%22)
[](https://codecov.io/gh/narugo1992/pytest_httpx_recorder)

[](https://github.com/narugo1992/pytest_httpx_recorder/stargazers)
[](https://github.com/narugo1992/pytest_httpx_recorder/network)

[](https://github.com/narugo1992/pytest_httpx_recorder/issues)
[](https://github.com/narugo1992/pytest_httpx_recorder/pulls)
[](https://github.com/narugo1992/pytest_httpx_recorder/graphs/contributors)
[](https://github.com/narugo1992/pytest_httpx_recorder/blob/master/LICENSE)
Recorder feature based on pytest_httpx, like recorder feature in responses
## Installation
```shell
pip install pytest_httpx_recorder
```
For more information about installation, you can refer
to [Installation](https://narugo1992.github.io/pytest_httpx_recorder/main/tutorials/installation/index.html).
## Record the Requests
```python
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
```python
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()
```
Raw data
{
"_id": null,
"home_page": "https://github.com/narugo1992/pytest_httpx_recorder",
"name": "pytest-httpx-recorder",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "Recorder feature based on pytest_httpx,like recorder feature in responses.",
"author": "narugo1992",
"author_email": "narugo992@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/d6/6f/b46552db25809cdfca1ecb1c406646aa2c8de3158b458db7cc370fdc9989/pytest_httpx_recorder-0.0.1.tar.gz",
"platform": null,
"description": "# pytest_httpx_recorder\n\n[](https://pypi.org/project/pytest_httpx_recorder/)\n\n\n\n\n[](https://github.com/narugo1992/pytest_httpx_recorder/actions?query=workflow%3A%22Code+Test%22)\n[](https://github.com/narugo1992/pytest_httpx_recorder/actions?query=workflow%3A%22Package+Release%22)\n[](https://codecov.io/gh/narugo1992/pytest_httpx_recorder)\n\n\n[](https://github.com/narugo1992/pytest_httpx_recorder/stargazers)\n[](https://github.com/narugo1992/pytest_httpx_recorder/network)\n\n[](https://github.com/narugo1992/pytest_httpx_recorder/issues)\n[](https://github.com/narugo1992/pytest_httpx_recorder/pulls)\n[](https://github.com/narugo1992/pytest_httpx_recorder/graphs/contributors)\n[](https://github.com/narugo1992/pytest_httpx_recorder/blob/master/LICENSE)\n\nRecorder feature based on pytest_httpx, like recorder feature in responses\n\n## Installation\n\n```shell\npip install pytest_httpx_recorder\n```\n\nFor more information about installation, you can refer\nto [Installation](https://narugo1992.github.io/pytest_httpx_recorder/main/tutorials/installation/index.html).\n\n## Record the Requests\n\n```python\nimport httpx\n\nfrom pytest_httpx_recorder.recorder import ResRecorder\n\nif __name__ == '__main__':\n recorder = ResRecorder()\n with recorder.record():\n client = httpx.Client(follow_redirects=True)\n client.get('https://danbooru.donmai.us/artists/167715.json')\n client.head(\n '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')\n\n # save to directory 'test_danbooru_simple'\n recorder.to_resset().save('test_danbooru_simple')\n\n```\n\n## Replay in Pytest\n\n```python\nimport httpx\nimport pytest\n\nfrom pytest_httpx_recorder.recorder import ResSet\n\n\n@pytest.fixture\ndef replay_from_test_danbooru_simple(httpx_mock):\n resset = ResSet.load('test_danbooru_simple')\n with resset.mock_context(httpx_mock):\n yield\n\n\ndef test_replay(replay_from_test_danbooru_simple):\n client = httpx.Client(follow_redirects=True)\n resp = client.get('https://danbooru.donmai.us/artists/167715.json')\n resp.raise_for_status()\n\n resp = client.head(\n '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')\n resp.raise_for_status()\n\n```\n",
"bugtrack_url": null,
"license": "Apache License, Version 2.0",
"summary": "Recorder feature based on pytest_httpx, like recorder feature in responses.",
"version": "0.0.1",
"project_urls": {
"Homepage": "https://github.com/narugo1992/pytest_httpx_recorder"
},
"split_keywords": [
"recorder feature based on pytest_httpx",
"like recorder feature in responses."
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "917fccadf9daa6bc17a5459181c2fda4c39a2d8d63b7cb9004eddfcc3198c9fb",
"md5": "b6e479890411af06191cbd23e42f976b",
"sha256": "d8b74ba86359a892d4acf0f79f31096bace65546b7f5107c3bc20dfb1022129d"
},
"downloads": -1,
"filename": "pytest_httpx_recorder-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b6e479890411af06191cbd23e42f976b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 12662,
"upload_time": "2024-01-04T11:11:01",
"upload_time_iso_8601": "2024-01-04T11:11:01.713542Z",
"url": "https://files.pythonhosted.org/packages/91/7f/ccadf9daa6bc17a5459181c2fda4c39a2d8d63b7cb9004eddfcc3198c9fb/pytest_httpx_recorder-0.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d66fb46552db25809cdfca1ecb1c406646aa2c8de3158b458db7cc370fdc9989",
"md5": "da4410655cdf679397e4db176168fd83",
"sha256": "3d491135b1b323ad1238416ab93617cf9c9e8782275c400a6f3b036f20d37545"
},
"downloads": -1,
"filename": "pytest_httpx_recorder-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "da4410655cdf679397e4db176168fd83",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 13320,
"upload_time": "2024-01-04T11:11:03",
"upload_time_iso_8601": "2024-01-04T11:11:03.819479Z",
"url": "https://files.pythonhosted.org/packages/d6/6f/b46552db25809cdfca1ecb1c406646aa2c8de3158b458db7cc370fdc9989/pytest_httpx_recorder-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-04 11:11:03",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "narugo1992",
"github_project": "pytest_httpx_recorder",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "hbutils",
"specs": [
[
">=",
"0.9.0"
]
]
},
{
"name": "httpx",
"specs": []
},
{
"name": "pytest_httpx",
"specs": []
},
{
"name": "pytest",
"specs": []
},
{
"name": "pyyaml",
"specs": []
}
],
"lcname": "pytest-httpx-recorder"
}