Skip to content

Commit 7e96a94

Browse files
committed
TEST: Add expires deprecator to xfail on ExpiredDeprecationError
1 parent 943e5e8 commit 7e96a94

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

nibabel/testing/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import unittest
1818

19+
import pytest
1920
import numpy as np
2021
from numpy.testing import assert_array_equal
2122

@@ -223,3 +224,15 @@ def setUp(self):
223224
if self.__class__.__name__.startswith('_'):
224225
raise unittest.SkipTest("Base test case - subclass to run")
225226
super().setUp()
227+
228+
229+
def expires(version):
230+
"Decorator to mark a test as xfail with ExpiredDeprecationError after version"
231+
from packaging.version import Version
232+
from nibabel import __version__ as nbver
233+
from nibabel.deprecator import ExpiredDeprecationError
234+
235+
if Version(nbver) < Version(version):
236+
return lambda x: x
237+
238+
return pytest.mark.xfail(raises=ExpiredDeprecationError)

0 commit comments

Comments
 (0)