Skip to main content

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

Project description


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


pip install pytest-httpdbg


pytest custom options

  --httpdbg             record HTTP(S) requests
                        save httpdbg traces in a directory
  --httpdbg-no-clean    do not clean the httpdbg directory
                        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.


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

import os

import pytest

from pytest_httpdbg import httpdbg_record_filename

def pytest_runtest_makereport(item, call):
    pytest_html = item.config.pluginmanager.getplugin("html")
    outcome = yield
    report = outcome.get_result()
    extras = getattr(report, "extras", [])

    if call.when == "call":
        if httpdbg_record_filename in item.stash:
            report.extras = extras

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.


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-httpdbg-0.3.3.tar.gz (8.7 kB view hashes)

Uploaded Source

Built Distribution

pytest_httpdbg-0.3.3-py3-none-any.whl (8.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page