Skip to content

Commit

Permalink
Add decorator to ignore metpy deprecation warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrleeman committed Sep 27, 2018
1 parent b7f9799 commit 9e107f0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions metpy/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

from __future__ import absolute_import

import functools

import numpy as np
import numpy.testing
from pint import DimensionalityError
Expand All @@ -18,6 +20,7 @@

from metpy.calc import wind_components
from metpy.cbook import get_test_data
from metpy.deprecation import MetpyDeprecationWarning
from .units import units


Expand Down Expand Up @@ -194,3 +197,16 @@ def patch_round(monkeypatch):
to use numpy's throughout.
"""
monkeypatch.setitem(__builtins__, 'round', np.round)


def ignore_deprecation(func):
"""Decorate a function to swallow metpy deprecation warnings, making sure they are present.
This should be used on deprecation function tests to make sure the deprecation warnings
are not failing the tests, but still allow testing of those functions.
"""
@functools.wraps(func)
def wrapper(*args, **kwargs):
with pytest.warns(MetpyDeprecationWarning):
return func(*args, **kwargs)
return wrapper

0 comments on commit 9e107f0

Please sign in to comment.