This repository was archived by the owner on Nov 11, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
This repository was archived by the owner on Nov 11, 2025. It is now read-only.
pytest -v does not show the 'msg' contents in the report for subtests #6
Copy link
Copy link
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
For the following test function, code and test details unimportant:
def test_apifail_inventory_no_object_invs(subtests):
"""Confirm no-objects inventories don't import."""
inv = soi.Inventory()
with subtests.test(msg="plain"):
with pytest.raises(TypeError):
soi.Inventory(inv.data_file())
with subtests.test(msg="zlib"):
with pytest.raises((TypeError, ValueError)):
soi.Inventory(soi.compress(inv.data_file()))
d = {"project": "test", "version": "0.0", "count": 0}
with subtests.test(msg="json"):
with pytest.raises(ValueError):
soi.Inventory(d)The following output is obtained; the contents of msg are not included in the line of the report for each subtest (marked with arrows):
>pytest -vk no_object
================================================= test session starts =================================================
platform win32 -- Python 3.6.3, pytest-4.4.0, py-1.8.0, pluggy-0.9.0 -- c:\temp\git\sphobjinv\env\scripts\python.exe
cachedir: .pytest_cache
rootdir: C:\Temp\git\sphobjinv, inifile: tox.ini
plugins: timeout-1.3.3, subtests-0.1.0, ordering-0.6, cov-2.6.1
collected 173 items / 172 deselected / 1 selected
tests/test_api_fail.py::test_apifail_inventory_no_object_invs PASSED [100%] <---
tests/test_api_fail.py::test_apifail_inventory_no_object_invs PASSED [100%] <---
tests/test_api_fail.py::test_apifail_inventory_no_object_invs PASSED [100%] <---
tests/test_api_fail.py::test_apifail_inventory_no_object_invs PASSED [100%]
====================================== 1 passed, 172 deselected in 0.30 seconds =======================================
This is problematic when a subtest fails and something like --tb=line is used. After making a breaking edit to one of the subtests and rerunning:
>pytest -vk no_object --tb=line
================================================= test session starts =================================================
platform win32 -- Python 3.6.3, pytest-4.4.0, py-1.8.0, pluggy-0.9.0 -- c:\temp\git\sphobjinv\env\scripts\python.exe
cachedir: .pytest_cache
rootdir: C:\Temp\git\sphobjinv, inifile: tox.ini
plugins: timeout-1.3.3, subtests-0.1.0, ordering-0.6, cov-2.6.1
collected 173 items / 172 deselected / 1 selected
tests/test_api_fail.py::test_apifail_inventory_no_object_invs FAILED [100%] <===
tests/test_api_fail.py::test_apifail_inventory_no_object_invs PASSED [100%]
tests/test_api_fail.py::test_apifail_inventory_no_object_invs PASSED [100%]
tests/test_api_fail.py::test_apifail_inventory_no_object_invs PASSED [100%]
====================================================== FAILURES =======================================================
c:\temp\git\sphobjinv\src\sphobjinv\inventory.py:626: TypeError: Invalid Inventory source type
================================= 1 failed, 1 passed, 172 deselected in 0.34 seconds ==================================
It would be nice to have the msg reported with each subtest, so as to avoid having to rerun the test with expanded context to identify offending case(s).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request