pytest-dev / pytest-dev/pytest-html

Gathering some test run statistics at the end of the test run and displaying them in summary section

Open
#534 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Python
Stars
779
Forks
260
PR merge metrics
No merged PRs in 30d

Description

Hi all!

I have a situation where I do some REST API calls during pytest run. Each request is saved in DB with the session_id field which is either some random uuid generated in session scoped fixture or testrun_uid fixture from pytest-xdist

At the end of the session I would like to query my database that holds all needed data and gather some statistics, for example, a number of made requests/average response time and display it in the summary section.

I was thinking of using

def pytest_html_results_summary(prefix, summary, postfix):
    """Called before adding the summary section to the report"""

but the issue is there is no access to my session id fixture from there.

Has somebody faced the similar issue?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the pytest_html_results_summary hook and how session-scoped fixtures and pytest-xdist's testrun_uid are handled. Determine how end-of-session data could reach the summary section, then define tests covering collected request statistics and their display in the report summary.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.