Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
penguinpee opened this issue May 14, 2024 · 7 comments
Open

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

penguinpee opened this issue May 14, 2024 · 7 comments
Assignees
Labels
category: bug errors in the code or code behavior category: enhancement improvements of code or code behavior
Milestone

Comments

@penguinpee
Copy link

penguinpee commented May 14, 2024

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
Copy link
Contributor

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 mavaylon1 added category: bug errors in the code or code behavior category: enhancement improvements of code or code behavior labels May 15, 2024
@mavaylon1
Copy link
Contributor

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
Copy link
Author

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

@penguinpee
Copy link
Author

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
Copy link
Contributor

Wonderful. Let's see!

@penguinpee
Copy link
Author

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

@rly rly assigned rly and mavaylon1 and unassigned rly Jun 27, 2024
@rly rly added this to the Future milestone Jun 27, 2024
@musicinmybrain
Copy link
Contributor

Now that Fedora has pytest 8.3.3, I tried removing the patch corresponding to the workaround described in pytest-dev/pytest#12275 (comment) from Fedora’s python-hdmf package and didn’t observe any problems. I would say that this confirms the fix is in pytest 8.3, and this issue could be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: bug errors in the code or code behavior category: enhancement improvements of code or code behavior
Projects
None yet
Development

No branches or pull requests

4 participants