Skip to content

Commit

Permalink
TST: remove unnecessary test fixture (#70)
Browse files Browse the repository at this point in the history
The custom `warns` fixture is no longer necessary.
  • Loading branch information
ntessore authored Dec 1, 2023
1 parent fde7018 commit 69ec609
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 23 deletions.
20 changes: 0 additions & 20 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,10 @@
import warnings
from contextlib import contextmanager

import numpy as np
import pytest
from numba import config

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)
5 changes: 2 additions & 3 deletions tests/test_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import numpy as np
import pytest

from .conftest import warns


def map_catalog(m, catalog):
g = m(catalog)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 69ec609

Please sign in to comment.