hdmf-dev / hdmf

The Hierarchical Data Modeling Framework
http://hdmf.readthedocs.io
Other
46 stars 26 forks source link

[Bug]: Test collection fails for three tests with pytest 8.2.0 #1114

Open penguinpee opened 4 months ago

penguinpee commented 4 months ago

What happened?

Fedora is preparing to upgrade pytest to 8.x (currently 8.2.0). When running tests with that version of pytest, three test cannot be collected and fail with TypeError.

I used the approach below (using an empty directory) since I encountered issues with test collection previously. In this case, however, it didn't make a difference. Step 1 to 3 can be omitted, yielding the same result.

Steps to Reproduce

mkdir empty
cd empty
ln -s ../tests ../pyproject.toml .
pytest -vv

Traceback

============================================================================================================================= test session starts ==============================================================================================================================
platform linux -- Python 3.12.3, pytest-8.2.0, pluggy-1.5.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /builddir/build/BUILD/hdmf-3.13.0/empty
configfile: pyproject.toml
collected 1504 items / 3 errors                                                                                                                                                                                                                                                

==================================================================================================================================== ERRORS ====================================================================================================================================
______________________________________________________________________________________________________ ERROR collecting tests/unit/build_tests/mapper_tests/test_build.py ______________________________________________________________________________________________________
/usr/lib/python3.12/site-packages/_pytest/runner.py:341: in from_call
    result: Optional[TResult] = func()
/usr/lib/python3.12/site-packages/_pytest/runner.py:389: in collect
    return list(collector.collect())
/usr/lib/python3.12/site-packages/_pytest/unittest.py:90: in collect
    self.session._fixturemanager.parsefactories(self.newinstance(), self.nodeid)
/usr/lib/python3.12/site-packages/_pytest/unittest.py:75: in newinstance
    return self.obj("runTest")
E   TypeError: Can't instantiate abstract class BuildGroupExtAttrsMixin without an implementation for abstract method 'setUpBarHolderSpec'
______________________________________________________________________________________________________ ERROR collecting tests/unit/build_tests/mapper_tests/test_build.py ______________________________________________________________________________________________________
/usr/lib/python3.12/site-packages/_pytest/runner.py:341: in from_call
    result: Optional[TResult] = func()
/usr/lib/python3.12/site-packages/_pytest/runner.py:389: in collect
    return list(collector.collect())
/usr/lib/python3.12/site-packages/_pytest/unittest.py:90: in collect
    self.session._fixturemanager.parsefactories(self.newinstance(), self.nodeid)
/usr/lib/python3.12/site-packages/_pytest/unittest.py:75: in newinstance
    return self.obj("runTest")
E   TypeError: Can't instantiate abstract class BuildDatasetExtAttrsMixin without an implementation for abstract method 'get_refined_bar_data_spec'
_________________________________________________________________________________________________________ ERROR collecting tests/unit/validator_tests/test_validate.py _________________________________________________________________________________________________________
/usr/lib/python3.12/site-packages/_pytest/runner.py:341: in from_call
    result: Optional[TResult] = func()
/usr/lib/python3.12/site-packages/_pytest/runner.py:389: in collect
    return list(collector.collect())
/usr/lib/python3.12/site-packages/_pytest/unittest.py:90: in collect
    self.session._fixturemanager.parsefactories(self.newinstance(), self.nodeid)
/usr/lib/python3.12/site-packages/_pytest/unittest.py:75: in newinstance
    return self.obj("runTest")
E   TypeError: Can't instantiate abstract class ValidatorTestBase without an implementation for abstract method 'getSpecs'
=========================================================================================================================== short test summary info ============================================================================================================================
ERROR tests/unit/build_tests/mapper_tests/test_build.py::BuildGroupExtAttrsMixin - TypeError: Can't instantiate abstract class BuildGroupExtAttrsMixin without an implementation for abstract method 'setUpBarHolderSpec'
ERROR tests/unit/build_tests/mapper_tests/test_build.py::BuildDatasetExtAttrsMixin - TypeError: Can't instantiate abstract class BuildDatasetExtAttrsMixin without an implementation for abstract method 'get_refined_bar_data_spec'
ERROR tests/unit/validator_tests/test_validate.py::ValidatorTestBase - TypeError: Can't instantiate abstract class ValidatorTestBase without an implementation for abstract method 'getSpecs'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 3 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================================================================================================== 3 errors in 1.15s ===============================================================================================================================

Operating System

Linux

Python Executable

Python

Python Version

3.12

Package Versions

Python 3.12.3 pytest 8.2.0 hdmf 3.13.0 h5py 3.11.0 jsonschema 4.19.1 numpy 1.26.4 pandas 2.2.1 ruamel-yaml 0.18.5 scipy 1.11.3

We are using the packages available from the Fedora repositories. Listed are the dependencies for HDMF.

mavaylon1 commented 4 months ago

Hi @penguinpee I will discuss with the team. That being said the error does not appear on our scheduled test workflows as we are using pytest 7.4.3.

mavaylon1 commented 4 months ago

Hi @penguinpee after discussion with the team, we will update to pytest 8 in the future. I will post a deadline here when we have one.

penguinpee commented 4 months ago

Thanks! Should I have any news with regards to that issue, I'll post an update here.

penguinpee commented 4 months ago

This appears to be an issue in pytest trying to instantiat abstract classes: pytest-dev/pytest#12275

It will be fixed in release 8.3.0.

mavaylon1 commented 4 months ago

Wonderful. Let's see!

penguinpee commented 4 months ago

The workaround using conftest.py, mentioned in the ticket, works.