Skip to content

Commit

Permalink
use pytest to catch warning as silencing is harder with custom warnin…
Browse files Browse the repository at this point in the history
…g types
  • Loading branch information
Zeitsperre committed Jan 22, 2025
1 parent c383767 commit 4610b9a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/test_biasadjust.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import contextlib
import warnings

import numpy as np
Expand Down Expand Up @@ -145,8 +146,16 @@ def test_basic(
)

# For justification of warning filter, see: https://docs.xarray.dev/en/stable/generated/xarray.Dataset.polyfit.html
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=RankWarning)
if (
to_level is None
and bias_adjust_institution is None
and bias_adjust_project is None
):
# No warning is expected
context = contextlib.nullcontext()
else:
context = pytest.warns(RankWarning)
with context:
out = xs.adjust(
dtrain,
self.dsim.copy(),
Expand Down

0 comments on commit 4610b9a

Please sign in to comment.