Skip to content
This repository was archived by the owner on Nov 11, 2025. It is now read-only.
This repository was archived by the owner on Nov 11, 2025. It is now read-only.

Reports of nested test #45

Open
Open

Description

@Conchylicultor

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.

Activity

  1. nicoddemus commented on Jul 5, 2021

    @nicoddemus
    Member

    Makes sense, thanks for the suggestion!

  2. plaffitt commented on Dec 15, 2021

    @plaffitt

    This is definitely a must have!

  3. Conchylicultor commented on Sep 8, 2022

    @Conchylicultor
    Author

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions