Skip to content

Set __module__ = "pytest" for all public class types? #13812

@bluetech

Description

@bluetech

In #13804 I set the __module__ on some exception/enum types since it shows up in tracebacks. We also already set it on warning types.

I wonder if we should have a policy to set it for all types we expose? Or at least fixture types. The impetus is I was playing with subtests (#13738) and the failure looks like:

subtests = <_pytest.subtests.Subtests object at 0x7eff332f6900>

    def test_it(subtests: pytest.Subtests) -> None:
        for i in range(5):
            with subtests.test(i=i):
>               assert i % 2 == 0
E               assert (1 % 2) == 0

y.py:9: AssertionError

That's our automatically showing repr of local variables. I figure it would be nicer to show pytest.Subtests here and in similar cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: reportingrelated to terminal output and user-facing messages and errorstype: proposalproposal for a new feature, often to gather opinions or design the API around the new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions