diff --git a/tests/conftest.py b/tests/conftest.py index 70a306a..a8f3545 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,3 @@ -import warnings -from contextlib import contextmanager - import numpy as np import pytest from numba import config @@ -8,23 +5,6 @@ config.DISABLE_JIT = True -@contextmanager -def warns(*types): - if types == (None,): - with warnings.catch_warnings(): - warnings.simplefilter("error") - try: - yield - finally: - pass - else: - with pytest.warns(*types): - try: - yield - finally: - pass - - @pytest.fixture(scope="session") def rng(seed: int = 50) -> np.random.Generator: return np.random.default_rng(seed) diff --git a/tests/test_maps.py b/tests/test_maps.py index bfad8a5..14cc8fd 100644 --- a/tests/test_maps.py +++ b/tests/test_maps.py @@ -2,8 +2,6 @@ import numpy as np import pytest -from .conftest import warns - def map_catalog(m, catalog): g = m(catalog) @@ -82,6 +80,7 @@ def catalog(page): def test_visibility_map(nside, vmap): + from contextlib import nullcontext from unittest.mock import Mock from heracles.maps import VisibilityMap @@ -94,7 +93,7 @@ def test_visibility_map(nside, vmap): mapper = VisibilityMap(nside_out) - with warns(UserWarning if nside != nside_out else None): + with pytest.warns(UserWarning) if nside != nside_out else nullcontext(): result = mapper(catalog) assert result is not vmap