Skip to content

Commit

Permalink
Fix unit test that uses ITK image
Browse files Browse the repository at this point in the history
Had to filter out this batch of weird swig warnings because
in our pyproject.toml we configure pytest such that warnings
are treated as errors and this somehow causes a segfault from itk
when any image related functionality is touched. It only happened
on python3.12, not 3.9.

The warnings are things like

```
builtin type SwigPyObject has no __module__ attribute
```
  • Loading branch information
ebrahimebrahim committed Aug 13, 2024
1 parent 2af0f84 commit 6dbd767
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/test_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@

def test_bval_abstractness():
with pytest.raises(TypeError):
BvalResource() # type: ignore[abstract]
BvalResource()


def test_bvec_abstractness():
with pytest.raises(TypeError):
BvecResource() # type: ignore[abstract]
BvecResource()


def test_volume_abstractness():
with pytest.raises(TypeError):
VolumeResource() # type: ignore[abstract]
VolumeResource()


@pytest.fixture()
Expand Down Expand Up @@ -64,6 +64,7 @@ def test_bvec_inmemory_get(bvec_array):
assert (bvec.get() == bvec_array).all()


@pytest.mark.filterwarnings("ignore:builtin type [sS]wig.* has no __module__ attribute")
def test_volume_inmemory_get_array(volume_array):
vol = InMemoryVolumeResource(image=itk.image_from_array(volume_array))
assert (vol.get_array() == volume_array).all()
Expand Down

0 comments on commit 6dbd767

Please sign in to comment.