Skip to content

Bugfix 14412 subtests timing - #14670

Open
marcelomarkus wants to merge 3 commits into
pytest-dev:mainfrom
marcelomarkus:bugfix-14412-subtests-timing
Open

Bugfix 14412 subtests timing#14670
marcelomarkus wants to merge 3 commits into
pytest-dev:mainfrom
marcelomarkus:bugfix-14412-subtests-timing

Conversation

@marcelomarkus

@marcelomarkus marcelomarkus commented Jul 2, 2026

Copy link
Copy Markdown

Summary

Fixes #14412.

When using console_output_style="times" and running subtests, the timing information for subsequent subtests and the parent test's PASSED report is displayed as 0.000us (or similar tiny/incorrect durations).

This occurs because:

  1. Subtest reports (which have status categories starting with "subtests ") are not included in the terminal reporter's all_reports list.
  2. The timing tracking logic suppresses timing reports based on nodeid. Since all subtests and the parent test share the same nodeid, once the first report (usually setup) is processed, the nodeid is marked as reported and subsequent reports are ignored.

This PR fixes this by:

  1. Including "subtests " reports in the accumulation list for timing.
  2. Tracking reported timings by the unique Python object identity id(r) rather than r.nodeid, allowing independent timing reports.
  3. Keeping track of the current log report in self._current_logreport to ensure correct file location detection.

Attribution

This pull request was implemented with assistance from AI coding tools (Antigravity), credited via the Co-authored-by trailer in the commit history according to pytest's contribution guidelines.

Co-authored-by: Shimon Schwartz (@shimonenator)
Co-authored-by: Antigravity

@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Jul 2, 2026
@marcelomarkus
marcelomarkus force-pushed the bugfix-14412-subtests-timing branch from 78245f7 to 5f6d46e Compare July 2, 2026 01:00
@RonnyPfannschmidt

Copy link
Copy Markdown
Member

missing attributions

@marcelomarkus
marcelomarkus force-pushed the bugfix-14412-subtests-timing branch from 85be6a4 to 9643247 Compare August 13, 2026 11:27
@marcelomarkus

Copy link
Copy Markdown
Author

Updated the PR description with attributions (including AI co-author trailers and credits for @shimonenator) and checked the PR checklist. Thanks!

…t_style=times (pytest-dev#14412)

When console_output_style="times" is used with subtests, subtest timing
information and parent test PASSED reports were displayed with incorrect/zero durations.

This change includes subtest reports in terminal reporter aggregation and tracks
reported durations by object identity rather than nodeid.

Fixes pytest-dev#14412.

Co-authored-by: Shimon Schwartz <shimonenator@gmail.com>
Co-authored-by: Antigravity <antigravity@google.com>
@marcelomarkus
marcelomarkus force-pushed the bugfix-14412-subtests-timing branch from 9643247 to 672b551 Compare August 13, 2026 11:39
Comment thread src/_pytest/terminal.py Outdated
Comment thread src/_pytest/terminal.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect timing info when using subtests and console_output_style='times'

2 participants