Skip to content

BaseTestRawIO's setUp function deletes data needed for subsequent tests--on windows #1550

Open
@nikhilchandra

Description

@nikhilchandra

Describe the bug
I am putting together a unit test for issue #1546 (Link) but when I try to run unittest.main() from test_plexon2rawio.py, the code breaks.

To Reproduce

  1. I added a unit test called "test_check_enabled_flags" to TestPlexon2RawIO in test_plexon2rawio.py.
  2. I ran unittest.main() from test_plexon2rawio.py
  3. I think that BaseTestRawIO's setUp() function runs before each unit test. So before test_check_enabled_flags actually ran, setUp() called download_dataset() from neo.utils.dataset. On Line 69, the command "dataset=datalad.api.install(path=local_folder, source=repo)" triggered lazy loading of the data repository to my $HOME folder (files are all 1 KB large)
  4. Within download_dataset() there is a subsequent command on line 75 -- dataset.get(remote_path). With remote_path set to "plexon", this triggered the actual download of the plexon files. Here are the contents of the plexon folder after running this command: image
  5. My unit test ran fine.
  6. BaseTestRawIO has another unit test called test_read_all. Before this ran, setUp() was called again, and hence download_dataset(). This time, since ephy_testing_data had already been downloaded to my $HOME folder, and so a different branch of the if/else statement ran. On line 66, the command "repo.call_git(["checkout", "--force", "master"]) seemed to wipe out a subset of the files contained within the folder "plexon". Here are the contents after running this command:
    image
  7. When dataset.get(remote_path) runs for the 2nd time, nothing happens -- the files remain 1 KB.
  8. When test_read_all runs, it tries to load 4chDemoPL2.pl2, which is empty. All values contained in the file_info header are zero. Therefore, when the code tries to run compliance.count_element(reader) on Line 114 of common_rawio_test.py, it breaks on a ZeroDivisionError. Here is the error message:

Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Users\nikhil\Documents\Projects\python-neo\neo\rawio\baserawio.py", line 463, in segment_t_start return self._segment_t_start(block_index, seg_index) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\nikhil\Documents\Projects\python-neo\neo\rawio\plexon2rawio\plexon2rawio.py", line 379, in _segment_t_start return self.pl2reader.pl2_file_info.m_StartRecordingTime / self.pl2reader.pl2_file_info.m_TimestampFrequency ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ZeroDivisionError: float division by zero

Expected behaviour
I would expect subsequent calls to setUp() to not erase a subset of files as is currently happening.

Environment:

  • OS: Windows 11
  • Python version: 3.11.9
  • Neo version: 0.14.0dev
  • NumPy version: 1.26.4

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions