Skip to content

Commit

Permalink
Replaced decorator skipUnlessModule (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
david-zwicker authored Jan 3, 2024
1 parent 1434192 commit 78ab086
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
7 changes: 4 additions & 3 deletions tests/test_droplet_tracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"""

import numpy as np
import pytest

from pde.grids import UnitGrid
from pde.tools.misc import skipUnlessModule
from pde.tools.misc import module_available

from droplets.droplet_tracks import DropletTrack, DropletTrackList
from droplets.droplets import DiffuseDroplet, SphericalDroplet
Expand Down Expand Up @@ -41,7 +42,7 @@ def test_droplettrack():
assert t1 is not t2


@skipUnlessModule("h5py")
@pytest.mark.skipif(not module_available("h5py"), reason="requires `h5py` module")
def test_droplettrack_io(tmp_path):
"""test writing and reading droplet tracks"""
path = tmp_path / "test_droplettrack_io.hdf5"
Expand Down Expand Up @@ -83,7 +84,7 @@ def test_droplettracklist():
assert len(tl) == 1


@skipUnlessModule("h5py")
@pytest.mark.skipif(not module_available("h5py"), reason="requires `h5py` module")
def test_droplettracklist_io(tmp_path):
"""test writing and reading droplet tracks"""
path = tmp_path / "test_droplettracklist_io.hdf5"
Expand Down
6 changes: 3 additions & 3 deletions tests/test_droplets.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from scipy import integrate

from pde.grids import UnitGrid
from pde.tools.misc import skipUnlessModule
from pde.tools.misc import module_available
from pde.tools.numba import jit

from droplets import droplets
Expand Down Expand Up @@ -207,7 +207,7 @@ def test_from_data():
assert d1 is not d2


@skipUnlessModule("h5py")
@pytest.mark.skipif(not module_available("h5py"), reason="requires `h5py` module")
def test_triangulation_2d():
"""test the 2d triangulation of droplets"""
d1 = droplets.SphericalDroplet([1, 3], 5)
Expand All @@ -221,7 +221,7 @@ def test_triangulation_2d():
assert l == pytest.approx(drop.surface_area, rel=1e-3), drop


@skipUnlessModule("h5py")
@pytest.mark.skipif(not module_available("h5py"), reason="requires `h5py` module")
def test_triangulation_3d():
"""test the 3d triangulation of droplets"""
d1 = droplets.SphericalDroplet([1, 2, 3], 5)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_emulsion.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import pytest

from pde import CartesianGrid, MemoryStorage, ScalarField, UnitGrid
from pde.tools.misc import skipUnlessModule
from pde.tools.misc import module_available

from droplets import DiffuseDroplet, Emulsion, SphericalDroplet, droplets, emulsions
from droplets.emulsions import EmulsionTimeCourse
Expand Down Expand Up @@ -163,7 +163,7 @@ def test_emulsion_linked_data():
np.testing.assert_array_equal(e[1]._data_array, 5)


@skipUnlessModule("h5py")
@pytest.mark.skipif(not module_available("h5py"), reason="requires `h5py` module")
def test_emulsion_io(tmp_path):
"""test writing and reading emulsions"""
path = tmp_path / "test_emulsion_io.hdf5"
Expand Down Expand Up @@ -206,7 +206,7 @@ def test_timecourse():
assert len(t1) == 0


@skipUnlessModule("h5py")
@pytest.mark.skipif(not module_available("h5py"), reason="requires `h5py` module")
def test_timecourse_io(tmp_path):
"""test writing and reading emulsions time courses"""
path = tmp_path / "test_timecourse_io.hdf5"
Expand Down
4 changes: 2 additions & 2 deletions tests/test_trackers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import pytest

from pde import CahnHilliardPDE, CartesianGrid, DiffusionPDE, ScalarField, UnitGrid
from pde.tools.misc import skipUnlessModule
from pde.tools.misc import module_available

from droplets import LengthScaleTracker, SphericalDroplet
from droplets.emulsions import EmulsionTimeCourse


@skipUnlessModule("h5py")
@pytest.mark.skipif(not module_available("h5py"), reason="requires `h5py` module")
def test_emulsion_tracker(tmp_path):
"""test using the emulsions tracker"""
path = tmp_path / "test_emulsion_tracker.hdf5"
Expand Down

0 comments on commit 78ab086

Please sign in to comment.