Skip to content

Commit

Permalink
Rename writer
Browse files Browse the repository at this point in the history
  • Loading branch information
paddyroddy committed Aug 7, 2023
1 parent dcf9d74 commit 46dff6e
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@
)


def _write_h5_file(file_path: os.PathLike, test_objects) -> os.PathLike:
"""
Write a h5 file with test objects and return path.
"""
with btrack.io.HDF5FileHandler(file_path, "w") as h:
h.write_objects(test_objects)

return file_path


@pytest.fixture
def test_objects():
"""
Expand All @@ -34,24 +44,14 @@ def test_real_objects():
return btrack.io.import_CSV(TEST_DATA_PATH / "test_data.csv")


def write_h5_file(file_path: os.PathLike, test_objects) -> os.PathLike:
"""
Write a h5 file with test objects and return path.
"""
with btrack.io.HDF5FileHandler(file_path, "w") as h:
h.write_objects(test_objects)

return file_path


@pytest.fixture
def hdf5_file_path(tmp_path, test_objects) -> os.PathLike:
"""
Create and save a btrack HDF5 file, and return the path.
Note that this only saves segmentation results, not tracking results.
"""
return write_h5_file(tmp_path / "test.h5", test_objects)
return _write_h5_file(tmp_path / "test.h5", test_objects)


@pytest.fixture(params=["single", "list"])
Expand All @@ -64,11 +64,11 @@ def hdf5_file_path_or_paths(
Note that this only saves segmentation results, not tracking results.
"""
if request.param == "single":
return write_h5_file(tmp_path / "test.h5", test_objects)
return _write_h5_file(tmp_path / "test.h5", test_objects)
elif request.param == "list":
return [
write_h5_file(tmp_path / "test1.h5", test_objects),
write_h5_file(tmp_path / "test2.h5", test_objects),
_write_h5_file(tmp_path / "test1.h5", test_objects),
_write_h5_file(tmp_path / "test2.h5", test_objects),
]
else:
raise ValueError("Invalid requests.param, must be one of 'single' or 'list'")
Expand Down

0 comments on commit 46dff6e

Please sign in to comment.