pytest-dev / pytest-dev/pytest
Incorrect timing info when using subtests and console_output_style='times'
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 14.5k
- Forks
- 3.4k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 35
Description
pytest does not seem to report accurate timing info when using subtests and console_output_style = 'times':
pyproject.toml
[tool.pytest]
addopts = [
'--capture=tee-sys',
'-v'
]
console_output_style = 'times'
test_subtests.py
import time
import unittest
class Test(unittest.TestCase):
def test_subtests(self):
for i in range(3):
with self.subTest(i=i):
time.sleep(1)
Output:
$ pytest
==================================== test session starts =====================================
platform linux -- Python 3.14.4, pytest-9.1.0.dev332+gd4fde45a5, pluggy-1.6.0 -- /home/user/.venv-pyt/bin/python
cachedir: .pytest_cache
rootdir: /home/user/scratch
configfile: pyproject.toml
collected 1 item
test_subtests.py::Test::test_subtests SUBPASSED(i=0) 570.0us
test_subtests.py::Test::test_subtests SUBPASSED(i=1) 0.000us
test_subtests.py::Test::test_subtests SUBPASSED(i=2) 0.000us
test_subtests.py::Test::test_subtests PASSED 0.000us
============================ 1 passed, 3 subtests passed in 3.02s ============================
Version info
Package Version Editable project location
--------- ----------------------- -------------------------
iniconfig 2.3.0
packaging 26.1
pip 26.0.1
pluggy 1.6.0
Pygments 2.20.0
pytest 9.1.0.dev332+gd4fde45a5 /home/user/code/pytest
- pytest 9.0.3 and d4fde45a5
- Python 3.14.4
- Arch Linux
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied pyproject.toml configuration and test_subtests.py reproduction, then run pytest with console_output_style set to 'times'. Trace how subtest and final test timing is reported; done means the three subtests and the overall test show accurate elapsed durations rather than zero values.
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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100