Skip to content

Commit

Permalink
remove IntegrationTestUtils.treat_errors_as_warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
leoschwarz committed Sep 30, 2024
1 parent dc68ae8 commit f82f315
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
10 changes: 0 additions & 10 deletions src/depiction/misc/integration_test_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import warnings
from typing import Optional

from numpy.typing import ArrayLike
Expand All @@ -20,12 +19,3 @@ def populate_test_file(
with ImzmlWriteFile(path, imzml_mode).writer() as writer:
for mz_arr, int_arr, coordinates in zip(mz_arr_list, int_arr_list, coordinates_list):
writer.add_spectrum(mz_arr, int_arr, coordinates)

@staticmethod
def treat_warnings_as_error(test_case) -> None:
"""To be called from setUp."""
# TODO reuse or refactor (and move out of integration_test_utils and rather a more general test_utils?)
warnings_ctx = warnings.catch_warnings()
warnings_ctx.__enter__()
warnings.simplefilter("error")
test_case.addCleanup(warnings_ctx.__exit__, None, None, None)
13 changes: 11 additions & 2 deletions tests/unit/image/test_spatial_smoothing_sparse_aware.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
import warnings
from datetime import timedelta
from functools import cached_property

Expand All @@ -8,15 +9,23 @@
from xarray import DataArray

from depiction.image.spatial_smoothing_sparse_aware import SpatialSmoothingSparseAware
from depiction.misc.integration_test_utils import IntegrationTestUtils


def _treat_warnings_as_error(test_case) -> None:
"""To be called from setUp."""
# TODO reuse or refactor (and move out of integration_test_utils and rather a more general test_utils?)
warnings_ctx = warnings.catch_warnings()
warnings_ctx.__enter__()
warnings.simplefilter("error")
test_case.addCleanup(warnings_ctx.__exit__, None, None, None)


class TestSpatialSmoothingSparseAware(unittest.TestCase):
def setUp(self) -> None:
self.mock_kernel_size = 5
self.mock_kernel_std = 1.0
self.mock_use_interpolation = False
IntegrationTestUtils.treat_warnings_as_error(self)
_treat_warnings_as_error(self)

@cached_property
def mock_smooth(self) -> SpatialSmoothingSparseAware:
Expand Down

0 comments on commit f82f315

Please sign in to comment.