File tree 2 files changed +15
-1
lines changed
2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,8 @@ def wrapper(*args, **kwargs):
30
30
__tracebackhide__ = True
31
31
32
32
with warnings .catch_warnings ():
33
- warnings .simplefilter ("always" )
33
+ # only remove filters that would "error"
34
+ warnings .filters = [f for f in warnings .filters if f [0 ] != "error" ]
34
35
35
36
return func (* args , ** kwargs )
36
37
Original file line number Diff line number Diff line change @@ -164,3 +164,16 @@ def __array__(self):
164
164
getattr (xr .testing , func )(a , b )
165
165
166
166
assert len (w ) > 0
167
+
168
+ # ensure warnings still raise outside of assert_*
169
+ with pytest .raises (UserWarning ):
170
+ warnings .warn ("test" )
171
+
172
+ # ensure warnings stay ignored in assert_*
173
+ with warnings .catch_warnings (record = True ) as w :
174
+ # ignore warnings
175
+ warnings .filterwarnings ("ignore" )
176
+ with pytest .raises (AssertionError ):
177
+ getattr (xr .testing , func )(a , b )
178
+
179
+ assert len (w ) == 0
You can’t perform that action at this time.
0 commit comments