Skip to content

Commit

Permalink
test: ensure tests work with pytest 8.0
Browse files Browse the repository at this point in the history
This swaps from using the pytest-lazy-fixture plugin to the
pytest-lazy-fixtures plugin which supports the underlying changes in
pytest 8.
  • Loading branch information
jrs65 committed Feb 6, 2024
1 parent 850aa24 commit 85e5a2f
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 48 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Install pip dependencies
run: |
pip install ruff pytest black mpi4py pyinstrument psutil pytest-lazy-fixture
pip install ruff pytest black mpi4py pyinstrument psutil pytest-lazy-fixtures
pip install -r requirements.txt
pip install -e .[compression]
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
pip install -r requirements.txt
pip install zarr==2.11.3
pip install mpi4py numcodecs>=0.7.3 bitshuffle
pip install pytest pytest-lazy-fixture
pip install pytest pytest-lazy-fixtures
pip install -e .
- name: Run serial tests
Expand Down
60 changes: 30 additions & 30 deletions caput/tests/test_memh5.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import h5py
import numpy as np
import pytest
from pytest_lazyfixture import lazy_fixture
from pytest_lazy_fixtures import lf
import zarr
import copy

Expand Down Expand Up @@ -183,8 +183,8 @@ def assertAttrsEqual(a, b):
@pytest.mark.parametrize(
"test_file,file_open_function",
[
(lazy_fixture("filled_h5_file"), h5py.File),
(lazy_fixture("filled_zarr_file"), zarr.open_group),
(lf("filled_h5_file"), h5py.File),
(lf("filled_zarr_file"), zarr.open_group),
],
)
def test_file_sanity(test_file, file_open_function):
Expand All @@ -196,12 +196,12 @@ def test_file_sanity(test_file, file_open_function):
@pytest.mark.parametrize(
"test_file,file_open_function,file_format",
[
(lazy_fixture("filled_h5_file"), h5py.File, None),
(lazy_fixture("filled_zarr_file"), zarr.open_group, None),
(lazy_fixture("filled_zarrzip_file"), zarr.open_group, None),
(lazy_fixture("filled_h5_file"), h5py.File, fileformats.HDF5),
(lazy_fixture("filled_zarr_file"), zarr.open_group, fileformats.Zarr),
(lazy_fixture("filled_zarrzip_file"), zarr.open_group, fileformats.Zarr),
(lf("filled_h5_file"), h5py.File, None),
(lf("filled_zarr_file"), zarr.open_group, None),
(lf("filled_zarrzip_file"), zarr.open_group, None),
(lf("filled_h5_file"), h5py.File, fileformats.HDF5),
(lf("filled_zarr_file"), zarr.open_group, fileformats.Zarr),
(lf("filled_zarrzip_file"), zarr.open_group, fileformats.Zarr),
],
)
def test_to_from_file(test_file, file_open_function, file_format):
Expand All @@ -223,8 +223,8 @@ def test_to_from_file(test_file, file_open_function, file_format):
@pytest.mark.parametrize(
"test_file,file_format",
[
(lazy_fixture("filled_h5_file"), fileformats.HDF5),
(lazy_fixture("filled_zarr_file"), fileformats.Zarr),
(lf("filled_h5_file"), fileformats.HDF5),
(lf("filled_zarr_file"), fileformats.Zarr),
],
)
def test_memdisk(test_file, file_format):
Expand Down Expand Up @@ -253,8 +253,8 @@ def test_memdisk(test_file, file_format):
@pytest.mark.parametrize(
"test_file,file_format",
[
(lazy_fixture("filled_h5_file"), fileformats.HDF5),
(lazy_fixture("filled_zarr_file"), fileformats.Zarr),
(lf("filled_h5_file"), fileformats.HDF5),
(lf("filled_zarr_file"), fileformats.Zarr),
],
)
def test_compression(test_file, file_format, compression, compression_opts, chunks):
Expand Down Expand Up @@ -302,10 +302,10 @@ class TempSubClass(memh5.MemDiskGroup):
@pytest.mark.parametrize(
"test_file,file_format",
[
(lazy_fixture("h5_file"), fileformats.HDF5),
(lazy_fixture("zarr_file"), fileformats.Zarr),
(lazy_fixture("h5_file"), None),
(lazy_fixture("zarr_file"), None),
(lf("h5_file"), fileformats.HDF5),
(lf("zarr_file"), fileformats.Zarr),
(lf("h5_file"), None),
(lf("zarr_file"), None),
],
)
def test_io(test_file, file_format):
Expand Down Expand Up @@ -395,9 +395,9 @@ def zarrzip_basiccont_file(zarr_basiccont_file):
@pytest.mark.parametrize(
"test_file,file_format",
[
(lazy_fixture("h5_basiccont_file"), fileformats.HDF5),
(lazy_fixture("zarr_basiccont_file"), fileformats.Zarr),
(lazy_fixture("zarrzip_basiccont_file"), fileformats.Zarr),
(lf("h5_basiccont_file"), fileformats.HDF5),
(lf("zarr_basiccont_file"), fileformats.Zarr),
(lf("zarrzip_basiccont_file"), fileformats.Zarr),
],
)
def test_access(test_file, file_format):
Expand All @@ -420,8 +420,8 @@ def test_access(test_file, file_format):
@pytest.mark.parametrize(
"test_file,file_format",
[
(lazy_fixture("h5_basiccont_file"), fileformats.HDF5),
(lazy_fixture("zarr_basiccont_file"), fileformats.Zarr),
(lf("h5_basiccont_file"), fileformats.HDF5),
(lf("zarr_basiccont_file"), fileformats.Zarr),
],
)
def test_history(test_file, file_format):
Expand Down Expand Up @@ -459,8 +459,8 @@ def test_history(test_file, file_format):
@pytest.mark.parametrize(
"test_file,file_format",
[
(lazy_fixture("h5_file"), fileformats.HDF5),
(lazy_fixture("zarr_file"), fileformats.Zarr),
(lf("h5_file"), fileformats.HDF5),
(lf("zarr_file"), fileformats.Zarr),
],
)
def test_to_from__file_unicode(test_file, file_format):
Expand Down Expand Up @@ -519,8 +519,8 @@ def test_to_from__file_unicode(test_file, file_format):
@pytest.mark.parametrize(
"test_file,file_format",
[
(lazy_fixture("h5_file"), fileformats.HDF5),
(lazy_fixture("zarr_file"), fileformats.Zarr),
(lf("h5_file"), fileformats.HDF5),
(lf("zarr_file"), fileformats.Zarr),
],
)
def test_failure(test_file, file_format):
Expand All @@ -537,8 +537,8 @@ def test_failure(test_file, file_format):
@pytest.mark.parametrize(
"test_file,file_format",
[
(lazy_fixture("h5_file"), fileformats.HDF5),
(lazy_fixture("zarr_file"), fileformats.Zarr),
(lf("h5_file"), fileformats.HDF5),
(lf("zarr_file"), fileformats.Zarr),
],
)
def test_to_from_hdf5(test_file, file_format):
Expand Down Expand Up @@ -567,8 +567,8 @@ def test_to_from_hdf5(test_file, file_format):
@pytest.mark.parametrize(
"test_file,file_format",
[
(lazy_fixture("h5_file"), fileformats.HDF5),
(lazy_fixture("zarr_file"), fileformats.Zarr),
(lf("h5_file"), fileformats.HDF5),
(lf("zarr_file"), fileformats.Zarr),
],
)
def test_json_failure(test_file, file_format):
Expand Down
10 changes: 5 additions & 5 deletions caput/tests/test_memh5_parallel.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Unit tests for the parallel features of the memh5 module."""

import pytest
from pytest_lazyfixture import lazy_fixture
from pytest_lazy_fixtures import lf
import numpy as np
import h5py
import zarr
Expand Down Expand Up @@ -62,9 +62,9 @@ def test_create_dataset():
@pytest.mark.parametrize(
"test_file,file_open_function,file_format",
[
(lazy_fixture("h5_file_distributed"), h5py.File, fileformats.HDF5),
(lf("h5_file_distributed"), h5py.File, fileformats.HDF5),
(
lazy_fixture("zarr_file_distributed"),
lf("zarr_file_distributed"),
zarr.open_group,
fileformats.Zarr,
),
Expand Down Expand Up @@ -173,9 +173,9 @@ def test_io(
@pytest.mark.parametrize(
"test_file,file_open_function,file_format",
[
(lazy_fixture("h5_file_distributed"), h5py.File, fileformats.HDF5),
(lf("h5_file_distributed"), h5py.File, fileformats.HDF5),
(
lazy_fixture("zarr_file_distributed"),
lf("zarr_file_distributed"),
zarr.open_group,
fileformats.Zarr,
),
Expand Down
6 changes: 3 additions & 3 deletions caput/tests/test_mpiarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from typing import Union
from packaging import version
import pytest
from pytest_lazyfixture import lazy_fixture
from pytest_lazy_fixtures import lf
import h5py
import numpy as np
import zarr
Expand Down Expand Up @@ -126,9 +126,9 @@ def test_wrap():
@pytest.mark.parametrize(
"filename, file_open_function, file_format",
[
(lazy_fixture("h5_file_distributed"), h5py.File, fileformats.HDF5),
(lf("h5_file_distributed"), h5py.File, fileformats.HDF5),
(
lazy_fixture("zarr_file_distributed"),
lf("zarr_file_distributed"),
zarr.open_group,
fileformats.Zarr,
),
Expand Down
10 changes: 5 additions & 5 deletions caput/tests/test_selection.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Serial version of the selection tests."""

import pytest
from pytest_lazyfixture import lazy_fixture
from pytest_lazy_fixtures import lf
import numpy as np

from caput.memh5 import MemGroup
Expand Down Expand Up @@ -40,8 +40,8 @@ def zarr_file_select(datasets, zarr_file):
@pytest.mark.parametrize(
"container_on_disk, file_format",
[
(lazy_fixture("h5_file_select"), fileformats.HDF5),
(lazy_fixture("zarr_file_select"), fileformats.Zarr),
(lf("h5_file_select"), fileformats.HDF5),
(lf("zarr_file_select"), fileformats.Zarr),
],
)
def test_file_select(container_on_disk, file_format):
Expand All @@ -57,9 +57,9 @@ def test_file_select(container_on_disk, file_format):
@pytest.mark.parametrize(
"container_on_disk, file_format",
[
(lazy_fixture("h5_file_select"), fileformats.HDF5),
(lf("h5_file_select"), fileformats.HDF5),
pytest.param(
lazy_fixture("zarr_file_select"),
lf("zarr_file_select"),
fileformats.Zarr,
marks=pytest.mark.xfail(reason="Zarr doesn't support index selections."),
),
Expand Down
6 changes: 3 additions & 3 deletions caput/tests/test_selection_parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from mpi4py import MPI
import numpy as np
import pytest
from pytest_lazyfixture import lazy_fixture
from pytest_lazy_fixtures import lf

from caput import mpiutil, mpiarray, fileformats
from caput.memh5 import MemGroup
Expand Down Expand Up @@ -51,8 +51,8 @@ def xfail_zarr_listsel(request):
@pytest.mark.parametrize(
"file_name, file_format",
[
(lazy_fixture("h5_file"), fileformats.HDF5),
(lazy_fixture("zarr_file"), fileformats.Zarr),
(lf("h5_file"), fileformats.HDF5),
(lf("zarr_file"), fileformats.Zarr),
],
)
@pytest.mark.parametrize("fsel", [slice(1, 8, 2), slice(5, 8, 2)])
Expand Down

0 comments on commit 85e5a2f

Please sign in to comment.