Donders-Institute / multiecho

Combine multiple-echoes from a multi-echo BOLD fMRI acquisition.
Apache License 2.0
6 stars 2 forks source link

The sole test does not seem to work #16

Open musicinmybrain opened 1 year ago

musicinmybrain commented 1 year ago
python3.11 -m venv _e
. _e/bin/activate
pip install -e .
pip install pytest
python -m pytest
============================= test session starts ==============================
platform linux -- Python 3.11.3, pytest-7.4.0, pluggy-1.2.0
rootdir: /home/ben/src/multiecho
collected 1 item                                                               

tests/test_load_me_data.py F                                             [100%]

=================================== FAILURES ===================================
_________________________ MyUnitTest.test_load_me_data _________________________

self = <tests.test_load_me_data.MyUnitTest testMethod=test_load_me_data>

    def test_load_me_data(self):
>       with patch('multiecho.combination.logger') as log_mock:

tests/test_load_me_data.py:8: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib64/python3.11/unittest/mock.py:1437: in __enter__
    original, local = self.get_original()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <unittest.mock._patch object at 0x7f2373b00290>

    def get_original(self):
        target = self.getter()
        name = self.attribute

        original = DEFAULT
        local = False

        try:
            original = target.__dict__[name]
        except (AttributeError, KeyError):
            original = getattr(target, name, DEFAULT)
        else:
            local = True

        if name in _builtins and isinstance(target, ModuleType):
            self.create = True

        if not self.create and original is DEFAULT:
>           raise AttributeError(
                "%s does not have the attribute %r" % (target, name)
            )
E           AttributeError: <module 'multiecho.combination' from '/home/ben/src/multiecho/multiecho/combination.py'> does not have the attribute 'logger'

/usr/lib64/python3.11/unittest/mock.py:1410: AttributeError
=========================== short test summary info ============================
FAILED tests/test_load_me_data.py::MyUnitTest::test_load_me_data - AttributeError: <module 'multiecho.combination' from '/home/ben/src/multiec...
============================== 1 failed in 0.24s ===============================

(Using an older Python version such as 3.9 or 3.6 does not make a difference.)

Perhaps this test is just a placeholder, and not intended to be usable?

marcelzwiers commented 1 year ago

I think @dangom had started to set up the unit tests, using a placeholder indeed, but never got to implement the intended tests. I am not using unittest myself (I prefer pytest), so I am leaving this issue open for anyone to fix (sorry)