pytest-recorder


Namepytest-recorder JSON
Version 0.6.0 PyPI version JSON
download
home_pageNone
SummaryPytest plugin, meant to facilitate unit tests writing for tools consumming Web APIs.
upload_time2025-10-21 15:53:28
maintainerNone
docs_urlNone
authorChavithra Parana
requires_python<4.0,>=3.10
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 1. TL;DR example
STEP 1

Write this code:


# File tests/some_module.py

```python
@pytest.mark.record_curl
@pytest.mark.record_ftp
@pytest.mark.record_http
@pytest.mark.record_time
@pytest.mark.record_verify_screen
def test_some_test(record):
    some_python_object = ...

    record.add_verify(object=some_python_object)
```

STEP 2

Run:

pytest tests/some_module.py --record

It will:

Save all the Curl and urllib3 requests, as well as interactions with `ftplib`.

Save the execution datetime

Save the screen output

Save the data you provide to recorder object

STEP 3

Run:

pytest tests/some_module.py

It will:

Reuse the stored Curl and urllib3 requests

Reuse the same datetime to execute the test

Compare the current screen output to the previous one and raise and exception if different

Compare the current recorder object data to the previous one and raise and exception if different

# 2. Detailed example
CODE

```python
@pytest.mark.record_curl
@pytest.mark.record_http
@pytest.mark.record_time(date=datetime(2023, 3, 1, 12, 0, 0), tic=False)
@pytest.mark.record_verify_screen(hash=True)
def test_some_test(record):
    ...
    record.hash_only = True
    record.add_verify(object=df)
    record.add_verify(object=[df])

    recorder.add_verify(
        object=df,
    )
```

USAGE

pytest [FILE] [--record[=none,all,curl,ftp,http,object,screen,time]] [--record-no-overwrite] [--record-no-hash]

FILES

For a given test_function from test_module, we will have the following files:

/tests/test_module.py:test_function

/tests/record/curl/test_module/test_function.yaml

/tests/record/ftp/test_module/test_function.yaml

/tests/record/http/test_module/test_function.yaml

/tests/record/object/test_module/test_function.json

/tests/record/object_hash/test_module/test_function.txt/json?

/tests/record/screen/test_module/test_function.txt/json?

/tests/record/screen_hash/test_module/test_function.txt/json?

/tests/record/time/test_module/test_function.txt/json?

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pytest-recorder",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": null,
    "author": "Chavithra Parana",
    "author_email": "chavithra@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/3e/e4/2534047ae2a9d3ecfba2007e80d8dd6ba6b22cb2c2d7501c169f637aecf8/pytest_recorder-0.6.0.tar.gz",
    "platform": null,
    "description": "# 1. TL;DR example\nSTEP 1\n\nWrite this code:\n\n\n# File tests/some_module.py\n\n```python\n@pytest.mark.record_curl\n@pytest.mark.record_ftp\n@pytest.mark.record_http\n@pytest.mark.record_time\n@pytest.mark.record_verify_screen\ndef test_some_test(record):\n    some_python_object = ...\n\n    record.add_verify(object=some_python_object)\n```\n\nSTEP 2\n\nRun:\n\npytest tests/some_module.py --record\n\nIt will:\n\nSave all the Curl and urllib3 requests, as well as interactions with `ftplib`.\n\nSave the execution datetime\n\nSave the screen output\n\nSave the data you provide to recorder object\n\nSTEP 3\n\nRun:\n\npytest tests/some_module.py\n\nIt will:\n\nReuse the stored Curl and urllib3 requests\n\nReuse the same datetime to execute the test\n\nCompare the current screen output to the previous one and raise and exception if different\n\nCompare the current recorder object data to the previous one and raise and exception if different\n\n# 2. Detailed example\nCODE\n\n```python\n@pytest.mark.record_curl\n@pytest.mark.record_http\n@pytest.mark.record_time(date=datetime(2023, 3, 1, 12, 0, 0), tic=False)\n@pytest.mark.record_verify_screen(hash=True)\ndef test_some_test(record):\n    ...\n    record.hash_only = True\n    record.add_verify(object=df)\n    record.add_verify(object=[df])\n\n    recorder.add_verify(\n        object=df,\n    )\n```\n\nUSAGE\n\npytest [FILE] [--record[=none,all,curl,ftp,http,object,screen,time]] [--record-no-overwrite] [--record-no-hash]\n\nFILES\n\nFor a given test_function from test_module, we will have the following files:\n\n/tests/test_module.py:test_function\n\n/tests/record/curl/test_module/test_function.yaml\n\n/tests/record/ftp/test_module/test_function.yaml\n\n/tests/record/http/test_module/test_function.yaml\n\n/tests/record/object/test_module/test_function.json\n\n/tests/record/object_hash/test_module/test_function.txt/json?\n\n/tests/record/screen/test_module/test_function.txt/json?\n\n/tests/record/screen_hash/test_module/test_function.txt/json?\n\n/tests/record/time/test_module/test_function.txt/json?\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Pytest plugin, meant to facilitate unit tests writing for tools consumming Web APIs.",
    "version": "0.6.0",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cb1531b2750d14c18d2b6f18522eb28fce3ab861d074777e26d2a6a9b1dda9bf",
                "md5": "7ff644cf61e04728c3e300154ea3517e",
                "sha256": "b99bd6df12ce869264b01a0d53023702ce8f22cd657fcd2fcf4d069748dbee3a"
            },
            "downloads": -1,
            "filename": "pytest_recorder-0.6.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7ff644cf61e04728c3e300154ea3517e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 18678,
            "upload_time": "2025-10-21T15:53:27",
            "upload_time_iso_8601": "2025-10-21T15:53:27.290170Z",
            "url": "https://files.pythonhosted.org/packages/cb/15/31b2750d14c18d2b6f18522eb28fce3ab861d074777e26d2a6a9b1dda9bf/pytest_recorder-0.6.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3ee42534047ae2a9d3ecfba2007e80d8dd6ba6b22cb2c2d7501c169f637aecf8",
                "md5": "6d4bfd6b3cec0b8eeba35dd2e9e5a307",
                "sha256": "b6ff2f555337bb691e6956ae7a3c714b8cc38b270582339838e3519299ca3f75"
            },
            "downloads": -1,
            "filename": "pytest_recorder-0.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "6d4bfd6b3cec0b8eeba35dd2e9e5a307",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 13322,
            "upload_time": "2025-10-21T15:53:28",
            "upload_time_iso_8601": "2025-10-21T15:53:28.334264Z",
            "url": "https://files.pythonhosted.org/packages/3e/e4/2534047ae2a9d3ecfba2007e80d8dd6ba6b22cb2c2d7501c169f637aecf8/pytest_recorder-0.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-21 15:53:28",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "pytest-recorder"
}
        
Elapsed time: 2.40919s