Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to skip test for h5py if it is not installed #71

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions tests/test_xdmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,22 @@
import pytest
from unittest.mock import patch

try:
import h5py # noqa: F401

hash5py = True
except ImportError:
hash5py = False


@pytest.mark.parametrize("use_ctx_manager", [True, False])
@pytest.mark.parametrize("backend", ["h5py", "adios2"])
@pytest.mark.parametrize(
"backend",
[
pytest.param("h5py", marks=pytest.mark.skipif(not hash5py, reason="h5py is not installed")),
"adios2",
],
)
@pytest.mark.parametrize("degree", [1, 2, 3])
@pytest.mark.parametrize(
"cell_type", [dolfinx.mesh.CellType.triangle, dolfinx.mesh.CellType.quadrilateral]
Expand Down Expand Up @@ -69,7 +82,13 @@ def test_XDMFFile_2D(cell_type, degree, value_shape, backend, use_ctx_manager, t


@pytest.mark.parametrize("use_ctx_manager", [True, False])
@pytest.mark.parametrize("backend", ["h5py", "adios2"])
@pytest.mark.parametrize(
"backend",
[
pytest.param("h5py", marks=pytest.mark.skipif(not hash5py, reason="h5py is not installed")),
"adios2",
],
)
@pytest.mark.parametrize("degree", [1, 2, 3])
@pytest.mark.parametrize(
"cell_type", [dolfinx.mesh.CellType.tetrahedron, dolfinx.mesh.CellType.hexahedron]
Expand Down Expand Up @@ -209,6 +228,7 @@ def test_different_function_spaces_raises_ValueError(tmp_path):
"cell_type", [dolfinx.mesh.CellType.tetrahedron, dolfinx.mesh.CellType.hexahedron]
)
@pytest.mark.parametrize("value_shape", [(), (3,)])
@pytest.mark.skipif(not hash5py, reason="h5py not installed")
def test_h5py_fallback_3D(cell_type, degree, value_shape, tmp_path):
folder = MPI.COMM_WORLD.bcast(tmp_path, root=0)

Expand Down
Loading