Bug 2275075 - python-nibabel fails to build with pytest 8: Failed: DID NOT RAISE <class 'AssertionError'>
Summary: python-nibabel fails to build with pytest 8: Failed: DID NOT RAISE <class 'As...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: python-nibabel
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Sandro
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 2256331
TreeView+ depends on / blocked
 
Reported: 2024-04-15 08:38 UTC by Tomáš Hrnčiar
Modified: 2024-05-29 15:15 UTC (History)
6 users (show)

Fixed In Version: python-nibabel-5.2.1-3.fc41
Clone Of:
Environment:
Last Closed: 2024-05-29 15:15:16 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Fedora Package Sources python-nibabel pull-request 9 0 None None None 2024-05-29 08:17:16 UTC
Github nipy nibabel pull 1325 0 None open Add missing setUp() method 2024-05-29 12:46:55 UTC

Description Tomáš Hrnčiar 2024-04-15 08:38:31 UTC
python-nibabel fails to build with pytest 8.

=================================== FAILURES ===================================
_____________________ TestLoadSave.test_load_complex_file ______________________

self = <nibabel.streamlines.tests.test_streamlines.TestLoadSave testMethod=test_load_complex_file>

    def test_load_complex_file(self):
        for lazy_load in [False, True]:
>           for complex_filename in DATA['complex_filenames']:
E           KeyError: 'complex_filenames'

nibabel/streamlines/tests/test_streamlines.py:170: KeyError
______________________ TestLoadSave.test_load_empty_file _______________________

self = <nibabel.streamlines.tests.test_streamlines.TestLoadSave testMethod=test_load_empty_file>

    def test_load_empty_file(self):
        for lazy_load in [False, True]:
>           for empty_filename in DATA['empty_filenames']:
E           KeyError: 'empty_filenames'

nibabel/streamlines/tests/test_streamlines.py:142: KeyError
______________________ TestLoadSave.test_load_simple_file ______________________

self = <nibabel.streamlines.tests.test_streamlines.TestLoadSave testMethod=test_load_simple_file>

    def test_load_simple_file(self):
        for lazy_load in [False, True]:
>           for simple_filename in DATA['simple_filenames']:
E           KeyError: 'simple_filenames'

nibabel/streamlines/tests/test_streamlines.py:156: KeyError
_____________________ TestLoadSave.test_save_complex_file ______________________

self = <nibabel.streamlines.tests.test_streamlines.TestLoadSave testMethod=test_save_complex_file>

    def test_save_complex_file(self):
        complex_tractogram = Tractogram(
>           DATA['streamlines'],
            DATA['data_per_streamline'],
            DATA['data_per_point'],
            affine_to_rasmm=np.eye(4),
        )
E       KeyError: 'streamlines'

nibabel/streamlines/tests/test_streamlines.py:230: KeyError
____________________ TestLoadSave.test_save_from_generator _____________________

self = <nibabel.streamlines.tests.test_streamlines.TestLoadSave testMethod=test_save_from_generator>

    def test_save_from_generator(self):
>       tractogram = Tractogram(DATA['streamlines'], affine_to_rasmm=np.eye(4))
E       KeyError: 'streamlines'

nibabel/streamlines/tests/test_streamlines.py:285: KeyError
______________________ TestLoadSave.test_save_simple_file ______________________

self = <nibabel.streamlines.tests.test_streamlines.TestLoadSave testMethod=test_save_simple_file>

    def test_save_simple_file(self):
>       tractogram = Tractogram(DATA['streamlines'], affine_to_rasmm=np.eye(4))
E       KeyError: 'streamlines'

nibabel/streamlines/tests/test_streamlines.py:220: KeyError
___________________ TestLoadSave.test_save_sliced_tractogram ___________________

self = <nibabel.streamlines.tests.test_streamlines.TestLoadSave testMethod=test_save_sliced_tractogram>

    def test_save_sliced_tractogram(self):
>       tractogram = Tractogram(DATA['streamlines'], affine_to_rasmm=np.eye(4))
E       KeyError: 'streamlines'

nibabel/streamlines/tests/test_streamlines.py:265: KeyError
____________________ TestLoadSave.test_save_tractogram_file ____________________

self = <nibabel.streamlines.tests.test_streamlines.TestLoadSave testMethod=test_save_tractogram_file>

    def test_save_tractogram_file(self):
>       tractogram = Tractogram(DATA['streamlines'], affine_to_rasmm=np.eye(4))
E       KeyError: 'streamlines'

nibabel/streamlines/tests/test_streamlines.py:192: KeyError
____________________________ test_cmp_pkg_version_0 ____________________________

    def test_cmp_pkg_version_0():
        # Test version comparator
>       assert cmp_pkg_version(nib.__version__) == 0
E       AssertionError: assert 1 == 0
E        +  where 1 = cmp_pkg_version('5.2.1')
E        +    where '5.2.1' = nib.__version__

nibabel/tests/test_pkg_info.py:28: AssertionError
____________________________ test_unremoved_module _____________________________

    @mock.patch(_sched('MODULE'), [('3.0.0', ['nibabel.nifti1'])])
    def test_unremoved_module():
>       with pytest.raises(AssertionError):
E       Failed: DID NOT RAISE <class 'AssertionError'>

nibabel/tests/test_removalschedule.py:163: Failed
____________________________ test_unremoved_object _____________________________

    @mock.patch(_sched('OBJECT'), [('3.0.0', [('nibabel.nifti1', 'Nifti1Image')])])
    def test_unremoved_object():
>       with pytest.raises(AssertionError):
E       Failed: DID NOT RAISE <class 'AssertionError'>

nibabel/tests/test_removalschedule.py:169: Failed
_____________________________ test_unremoved_attr ______________________________

    @mock.patch(_sched('ATTRIBUTE'), [('3.0.0', [('nibabel.nifti1', 'Nifti1Image', 'affine')])])
    def test_unremoved_attr():
>       with pytest.raises(AssertionError):
E       Failed: DID NOT RAISE <class 'AssertionError'>

nibabel/tests/test_removalschedule.py:175: Failed

=========================== short test summary info ============================
FAILED nibabel/streamlines/tests/test_streamlines.py::TestLoadSave::test_load_complex_file
FAILED nibabel/streamlines/tests/test_streamlines.py::TestLoadSave::test_load_empty_file
FAILED nibabel/streamlines/tests/test_streamlines.py::TestLoadSave::test_load_simple_file
FAILED nibabel/streamlines/tests/test_streamlines.py::TestLoadSave::test_save_complex_file
FAILED nibabel/streamlines/tests/test_streamlines.py::TestLoadSave::test_save_from_generator
FAILED nibabel/streamlines/tests/test_streamlines.py::TestLoadSave::test_save_simple_file
FAILED nibabel/streamlines/tests/test_streamlines.py::TestLoadSave::test_save_sliced_tractogram
FAILED nibabel/streamlines/tests/test_streamlines.py::TestLoadSave::test_save_tractogram_file
FAILED nibabel/tests/test_pkg_info.py::test_cmp_pkg_version_0 - AssertionErro...
FAILED nibabel/tests/test_removalschedule.py::test_unremoved_module - Failed:...
FAILED nibabel/tests/test_removalschedule.py::test_unremoved_object - Failed:...
FAILED nibabel/tests/test_removalschedule.py::test_unremoved_attr - Failed: D...
= 12 failed, 5397 passed, 52 skipped, 15 xfailed, 33 xpassed, 3527 warnings in 134.11s (0:02:14) =

https://docs.pytest.org/en/stable/changelog.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/thrnciar/pytest/fedora-rawhide-x86_64/07248431-python-nibabel/

For all our attempts to build python-nibabel with pytest 8, see:
https://copr.fedorainfracloud.org/coprs/thrnciar/pytest/package/python-nibabel/

Let us know here if you have any questions.

Pytest 8 is planned to be included in Fedora 41. And this bugzilla is a
heads up before we merge new pytest into rawhide. For more info see a Fedora Change
proposal https://fedoraproject.org/wiki/Changes/Pytest_8

We'd appreciate help from the people who know this package best,
but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Tomáš Hrnčiar 2024-05-28 10:03:41 UTC
I wanted to report this problem upstream, but I can see their CI is passing with pytest 8.0.2 [0]. In my COPR it never worked with pytest>8 so there might be some fix in the master branch. Could you please try to build it from it? I have no experience with %forgesource macros and I wasn't able to modify spec file to make it work. Thank you.

[0] https://github.com/nipy/nibabel/actions/runs/9247532961/job/25436516987

Comment 2 Sandro 2024-05-28 10:20:25 UTC
I'll take a look. Building from master should be as simple as replacing `%global tag %{version}` with `%global branch master`.

Comment 3 Sandro 2024-05-28 11:02:09 UTC
I'm seeing the same failures building from master. However, there is:

https://github.com/nipy/nibabel/commit/e4facc17fbebeb92fa6fed600b9a349c6e373ee3

which points to:

https://github.com/scientific-python/pytest-doctestplus/issues/239

and Copr is currently using pytest 8.2.1.

It seems unrelated, though, since we do not run doctests. But maybe this is a regression in 8.2 that upstream hasn't come across yet due to the version being pinned to `<8.1`?

I'll dig a bit further. But it might be worth reporting upstream, nonetheless.

Comment 4 Sandro 2024-05-28 20:34:43 UTC
This appears to be a regression in pytest. Testing with pytest 8.0.2 all tests pass. With the next release, 8.1.1, the failures appear. I skimmed through the pytest changelog, but didn't notice anything that might explain the failures.

Comment 5 Sandro 2024-05-29 08:17:17 UTC
I dug a little deeper and was able to fix one failing test suite. The others remained a mystery. They appear to succeed when run inside the mock chroot without changing anything. I'm puzzled. But those tests are also less interesting to downstream. They are their to remind upstream in case they missed something in their workflow.

I sent the fix upstream and excluded the other failing tests. I'll talk to upstream letting them know.

Comment 6 Tomáš Hrnčiar 2024-05-29 09:35:06 UTC
Thank you for the investigation!

Comment 7 Tomáš Hrnčiar 2024-05-29 09:36:54 UTC
I am setting this to POST, for tracking purposes.

Comment 8 Sandro 2024-05-29 12:46:56 UTC
It seems Debian stumbled onto this issue as well and used a different approach to fixing the tests:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1071461

There's some discussion going on now in the upstream PR, but upstream developers have yet to join in.

Comment 9 Sandro 2024-05-29 12:54:00 UTC
Since this seems to be related to `setup()` and `teardown()` nose compatibility functions, I'm just reminded of my change proposal, which I'm still considering for submission:

https://fedoraproject.org/wiki/Changes/ReplaceNoseWithPynose

Comment 10 Sandro 2024-05-29 14:56:02 UTC
All tests are fixed now. The old nose compatibility functions needed replacement, though they were hiding in different places.


Note You need to log in before you can comment on or make changes to this bug.