pytest-subtests
pytest-subtests copied to clipboard
Reports of nested test
Currently:
def test_abc(subtests):
with subtests.test("a"):
with subtests.test("b"):
assert 1 == 2
Is reported as:
___________test_abc [b] ___________
It would be nice if it was reported as:
___________ test_abc [a/b] ___________
This is especially useful when calling the same function from within multiple sub-tests, when the same <name>
can be used in multiple subtests.test(<name>)
, but in different scopes.
Makes sense, thanks for the suggestion!
This is definitely a must have!
In case someone else is interested, I've implemented a small wrapper around subtests which add https://github.com/pytest-dev/pytest-subtests/issues/44 and https://github.com/pytest-dev/pytest-subtests/issues/45 (this issue):
from etils import epy
with_subtests = epy.testing.with_subtests # Needed to register the fixture for this file
@pytest.mark.usefixtures('with_subtests')
def test_dtype():
with epy.testing.subtests.test("a"): # Do not need to propagate a subtests object in sub-functions
with epy.testing.subtests.test("b"): # Nested subtest is reported as `a/b`
assert 1 == 2
Test reported as ___________ test_abc [a/b] ___________
As part of https://github.com/google/etils