Skip to content

Subclassing _pytest.Testdir does not work anymore. #17

Closed
@bnavigator

Description

@bnavigator

All tests using the mpi_testdir fixture fail with pytest 6.2:

[    3s] _____________________ ERROR at setup of test_mpi_file_name _____________________
[    3s] 
[    3s] request = <SubRequest 'mpi_testdir' for <Function test_mpi_file_name>>
[    3s] tmpdir_factory = TempdirFactory(_tmppath_factory=TempPathFactory(_given_basetemp=None, _trace=<pluggy._tracing.TagTracerSub object at 0x7f0bad081b38>, _basetemp=None))
[    3s] 
[    3s]     @pytest.fixture
[    3s]     def mpi_testdir(request, tmpdir_factory):
[    3s] >       return MPITestdir(request, tmpdir_factory)
[    3s] 
[    3s] tests/conftest.py:57: 
[    3s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[    3s] 
[    3s] self = <[AttributeError("'MPITestdir' object has no attribute '_pytester'",) raised in repr()] MPITestdir object at 0x7f0bacfad0f0>
[    3s] request = <SubRequest 'mpi_testdir' for <Function test_mpi_file_name>>
[    3s] tmpdir_factory = TempdirFactory(_tmppath_factory=TempPathFactory(_given_basetemp=None, _trace=<pluggy._tracing.TagTracerSub object at 0x7f0bad081b38>, _basetemp=None))
[    3s] 
[    3s]     def __init__(self, request, tmpdir_factory):
[    3s] >       super().__init__(request, tmpdir_factory)
[    3s] E       TypeError: __init__() takes 2 positional arguments but 3 were given
[    3s] 
[    3s] tests/conftest.py:22: TypeError

Pytest really does not want downstream projects to subclass Testdir:
pytest-dev/pytest#8017, pytest-dev/pytest@f1e6fdc

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions