Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reports of nested test #45

Open
Conchylicultor opened this issue Jul 5, 2021 · 3 comments
Open

Reports of nested test #45

Conchylicultor opened this issue Jul 5, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@Conchylicultor
Copy link

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.

@nicoddemus
Copy link
Member

Makes sense, thanks for the suggestion!

@nicoddemus nicoddemus added the enhancement New feature or request label Jul 5, 2021
@plaffitt
Copy link

This is definitely a must have!

@Conchylicultor
Copy link
Author

Conchylicultor commented Sep 8, 2022

In case someone else is interested, I've implemented a small wrapper around subtests which add #44 and #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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants