nipy / nibabel

Python package to access a cacophony of neuro-imaging file formats
http://nipy.org/nibabel/
Other
656 stars 259 forks source link

1 test fails: AssertionError: assert ['second', 'first'] == ['first', 'second'] #1375

Closed yurivict closed 1 month ago

yurivict commented 1 month ago
========================================================================================== ERRORS ===========================================================================================
______________________________________________________________________ ERROR at teardown of TestRunAllTests.test_first ______________________________________________________________________

cls = <class 'nibabel.tests.test_api_validators.TestRunAllTests'>

    @classmethod
    def teardown_class(cls):
        # Check that both validate_xxx tests got run
>       assert cls.run_tests == ['first', 'second']
E       AssertionError: assert ['second', 'first'] == ['first', 'second']
E         
E         At index 0 diff: 'second' != 'first'
E         
E         Full diff:
E           [
E         +     'second',
E               'first',
E         -     'second',
E           ]

nibabel/tests/test_api_validators.py:116: AssertionError
========================================================================================= FAILURES ==========================================================================================
__________________________________________________________________________________ TestEcatImage.test_file __________________________________________________________________________________

self = <nibabel.tests.test_ecat.TestEcatImage testMethod=test_file>

    def test_file(self):
>       assert Path(self.img.file_map['header'].filename) == Path(self.example_file)
E       AssertionError: assert PosixPath('tinypet_tmp.v') == PosixPath('/usr/ports/science/py-nibabel/work-py311/nibabel-5.3.0/nibabel/tests/data/tinypet.v')
E        +  where PosixPath('tinypet_tmp.v') = Path('tinypet_tmp.v')
E        +    where 'tinypet_tmp.v' = <nibabel.fileholders.FileHolder object at 0x3d17265d0650>.filename
E        +  and   PosixPath('/usr/ports/science/py-nibabel/work-py311/nibabel-5.3.0/nibabel/tests/data/tinypet.v') = Path('/usr/ports/science/py-nibabel/work-py311/nibabel-5.3.0/nibabel/tests/data/tinypet.v')
E        +    where '/usr/ports/science/py-nibabel/work-py311/nibabel-5.3.0/nibabel/tests/data/tinypet.v' = <nibabel.tests.test_ecat.TestEcatImage testMethod=test_file>.example_file

nibabel/tests/test_ecat.py:186: AssertionError

Version: 5.3.0 Python-3.11 FreeBSD 14.1

effigies commented 1 month ago

The first looks like a race condition for a test suite written before parallelizing tests. Should be straightforward. The second is a bit weirder... Will have a look tomorrow.

effigies commented 1 month ago

Okay, I really don't understand the second one.

We have:

https://github.com/nipy/nibabel/blob/3b1c7b3727e18be0222b00dfe369bad6f3dc707d/nibabel/tests/test_ecat.py#L180-L187

ecat_file is evidently '/usr/ports/science/py-nibabel/work-py311/nibabel-5.3.0/nibabel/tests/data/tinypet.v'.

When we load():

https://github.com/nipy/nibabel/blob/3b1c7b3727e18be0222b00dfe369bad6f3dc707d/nibabel/ecat.py#L1016-L1018

We call:

https://github.com/nipy/nibabel/blob/3b1c7b3727e18be0222b00dfe369bad6f3dc707d/nibabel/filebasedimages.py#L247-L250

which calls:

https://github.com/nipy/nibabel/blob/3b1c7b3727e18be0222b00dfe369bad6f3dc707d/nibabel/filebasedimages.py#L256-L289

The only place I see to change the filename is here:

https://github.com/nipy/nibabel/blob/3b1c7b3727e18be0222b00dfe369bad6f3dc707d/nibabel/filename_parser.py#L116-L118

Would you mind adding a breakpoint() after that line, running tox -e py311-x64-none -- tests/test_ecat.py -k test_file and then

(Pdb) from pprint import pprint
(Pdb) pprint(vars())
effigies commented 1 month ago

I've addressed the first issue. If you can provide more information on the second issue, please open a new issue referencing this one.