Skip to content

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

@lambda-aw

Description

@lambda-aw

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions