pytest icon indicating copy to clipboard operation
pytest copied to clipboard

Set `__module__ = "pytest"` for all public class types?

Open bluetech opened this issue 1 month ago • 1 comments

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.

bluetech avatar Oct 14 '25 06:10 bluetech