Skip to main content

pytest-httpdbg

A pytest plugin to record HTTP(S) requests with stack trace.

installation

pip install pytest-httpdbg

usage

pytest custom options

  --httpdbg             record HTTP(S) requests
  --httpdbg-dir=HTTPDBG_DIR
                        save httpdbg traces in a directory
  --httpdbg-no-clean    do not clean the httpdbg directory
  --httpdbg-initiator=HTTPDBG_INITIATOR
                        add a new initiator (package) for httpdbg

option httpdbg

Enables the record of the HTTP requests.

option httpdbg-dir

Indicates where to save the log files.

option httpdbg-no-clean

Does not clean existing log files if the log directory is not empty.

option http-initiator

An initiator is the function/method that is at the origin of the HTTP requests. By default, we already support some packages but you can add your own initiators.

To add a new package in the list of initiators, you can use the http-initiator command line argument.

You can use any package as an initiator, this is not limited to HTTP requests.

test report

When the test is finished (teardown step included), one log file in markdown format is written. The path to this log file is stashed in the item when the test starts (before the setup step), even if the file not exists yet.

pytest-html

You can copy the following code in your top-level conftest.py to include the logs into your pytest-html report.

import os

import pytest

from pytest_httpdbg import httpdbg_record_filename


@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item, call):
    pytest_html = item.config.pluginmanager.getplugin("html")
    outcome = yield
    report = outcome.get_result()    
    extra = getattr(report, "extra", [])

    if call.when == "setup":
        if httpdbg_record_filename in item.stash:
            extra.append(
                pytest_html.extras.url(
                    os.path.basename(item.stash[httpdbg_record_filename]), name="HTTPDBG"
                )
            )
            report.extra = extra

This example works if you use the same directory for the html test report file and the httpdbg logs.

pytest demo/ --httpdbg --httpdbg-dir report --html=report/report.html

If this is not the case, you must adapt it to your configuration.

Release files for pytest-httpdbg 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-httpdbg 0.3.1
File Size Uploaded
pytest-httpdbg-0.3.1.tar.gz 8.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-httpdbg 0.3.1
File Interpreter ABI Platform
pytest_httpdbg-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 17.3 kB

Release files / pytest-httpdbg-0.3.1.tar.gz

Download URL pytest-httpdbg-0.3.1.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
211205429c879b7c75d4daf0444e5017a0d6ec5de6b732da07f518b1478656fe
BLAKE2b-256 checksum
How to use checksums
5c49632018a1a973b7c55078083c8621ca8740ffba8bd805d2ddefc9c5d10c21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / pytest_httpdbg-0.3.1-py3-none-any.whl

Download URL pytest_httpdbg-0.3.1-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
50e4a475b32d2f4359985e0c10a81158ba4ad4d5e4b1beb90be3f42f75463e24
BLAKE2b-256 checksum
How to use checksums
e34378097efce39dcbdf39f972f5da0d18cb9d2978b8b845135ddd4cc2483907
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release history Release notifications | RSS feed

0.10.2

2 release files

0.10.1

2 release files

0.10.0

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.3

2 release files

0.3.2

2 release files

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page