aragilar / pytest-mpi

Pytest plugin for working with MPI
https://pytest-mpi.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
19 stars 7 forks source link

Subclassing _pytest.Testdir does not work anymore. #17

Closed bnavigator closed 3 years ago

bnavigator commented 3 years ago

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: https://github.com/pytest-dev/pytest/pull/8017, https://github.com/pytest-dev/pytest/pull/8017/commits/f1e6fdcddbfe8991935685ccc5049dd957ec4382

aragilar commented 3 years ago

Fixed in #28.