childmindresearch/bids2table

test_table_files fails because test case is incorrect

maouw opened this issue · 2 comments

test_table_files fails on c3f4c12 becase files[0] has metadata associated with it, whereas the test tries to assert that the metadata is empty.

Command:

pytest -vv --pdb -x --cov=bids2table

Output:

tests/test_table.py::test_table_files FAILED                                                                 [ 58%]
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> traceback >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

tab =     ds__dataset ds__dataset_type  ... finfo__link_target finfo__mod_time
0         ds001             None  ...        ... None    1.712859e+09
127       ds001             None  ...               None    1.712859e+09

[128 rows x 40 columns]

    def test_table_files(tab: BIDSTable):
        files = tab.files
        assert len(files) == 128
    
        file = files[0]
        assert file.path.exists()
        assert (file.root / file.relative_path).exists()
>       assert file.metadata == {}
E       AssertionError: assert {'RepetitionTime': 2.0, 'TaskName': 'balloon analog risk task'} == {}
E         
E         Left contains 2 more items:
E         {'RepetitionTime': 2.0, 'TaskName': 'balloon analog risk task'}
E         
E         Full diff:
E         - {}
E         + {
E         +     'RepetitionTime': 2.0,
E         +     'TaskName': 'balloon analog risk task',
E         + }

tests/test_table.py:51: AssertionError

Hi @maouw, thanks for your interest in the project and for opening this issue! I am struggling to reproduce your issue. Would you mind sharing your environment info? E.g. by running:

import platform
import sys
import pkg_resources


def print_environment_info():
    print("Platform:", platform.platform())
    print("Python:", sys.version)
    
    print("\nInstalled Packages:")
    installed_packages = {pkg.key: pkg.version for pkg in pkg_resources.working_set}
    for package, version in sorted(installed_packages.items()):
        print(f"{package}=={version}")

Ah, I think the issue is due to the files in the BIDSTable being in random order. In #29 I believe the issue should be fixed.