pytest-dev / pytest-dev/pytest-html

pytest 9.0: subtests feature causes the test to be reported twice - both failed and passed

Open
#981 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

hello,
while playing with new subtests feature in pytest 9.0, I found that sometimes the test is reported twice for some reason. could you check why is that?
thanks.

regards,
jaroslav

# pytest.ini

[pytest]
minversion = 9.0
; pytest-timeout: the test should be really short
timeout = 60
; pytest-html
generate_report_on_test = True
; test discovery
norecursedirs = _*
python_files = *.py
python_functions = *_test
;
addopts =
    -ra
    -s
    --junit-xml=report.xml
    --self-contained-html
    --html=report.html
    --ctrf=report.json
# my_test.py

from random import randint

from pytest import Subtests


def feat_test(subtests: Subtests):
    for i in range(10):
        with subtests.test(i):
            assert randint(0, 10) == i

report.html

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

Reproduce the report using pytest.ini and my_test.py with pytest 9.0 and the linked report.html as the reference symptom. Start by examining how pytest subtest outcomes are collected and rendered in the HTML report. Done means the test is represented once with the correct failed and passed status.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.