Skip to content

Commit

Permalink
Test reader with path and paths
Browse files Browse the repository at this point in the history
  • Loading branch information
dstansby committed May 23, 2022
1 parent 3621892 commit 03d9a04
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,27 @@ def test_objects():
return [create_test_object(id=i)[0] for i in range(10)]


@pytest.fixture
def hdf5_file_path(tmp_path, test_objects) -> Path:
def write_h5_file(file_path: Path, test_objects) -> Path:
"""
Write a h5 file with test objects and return path.
"""
with btrack.dataio.HDF5FileHandler(file_path, "w") as h:
h.write_objects(test_objects)

return file_path


@pytest.fixture(params=["single", "list"])
def hdf5_file_path(tmp_path, test_objects, request) -> Path:
"""
Create and save a btrack HDF5 file, and return the path.
Note that this only saves segmentation results, not tracking results.
"""
fn = Path(tmp_path) / "test.h5"

with btrack.dataio.HDF5FileHandler(fn, "w") as h:
h.write_objects(test_objects)

return fn
if request.param == "single":
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),
]

0 comments on commit 03d9a04

Please sign in to comment.