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 d4fde45
- Python 3.14.4
- Arch Linux
pytest does not seem to report accurate timing info when using subtests and
console_output_style = 'times':pyproject.toml
test_subtests.py
Output:
Version info