Skip to content

Commit e42b6fc

Browse files
committed
Fix: Replace deprecated pytest.warns(None) with warnings.catch_warnings()
The pytest.warns(None) syntax is no longer supported in pytest 9.x and raises a TypeError. This commit updates test_masked_dtype_change.py to use Python's standard warnings.catch_warnings() context manager instead.
1 parent 406c961 commit e42b6fc

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

plotpy/tests/unit/test_masked_dtype_change.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313

1414
from __future__ import annotations
1515

16+
import warnings
17+
1618
import numpy as np
17-
import pytest
1819

1920
from plotpy.builder import make
2021

@@ -41,7 +42,8 @@ def test_masked_image_dtype_change_from_float_to_uint8():
4142
item.set_data(new_data)
4243

4344
# This should not raise a RuntimeWarning
44-
with pytest.warns(None) as warning_list:
45+
with warnings.catch_warnings(record=True) as warning_list:
46+
warnings.simplefilter("always")
4547
item.update_mask()
4648

4749
# Check that no RuntimeWarning was raised
@@ -73,7 +75,8 @@ def test_masked_image_dtype_change_with_none_filling_value():
7375
item.set_data(new_data)
7476

7577
# This should not raise a RuntimeWarning
76-
with pytest.warns(None) as warning_list:
78+
with warnings.catch_warnings(record=True) as warning_list:
79+
warnings.simplefilter("always")
7780
item.update_mask()
7881

7982
# Check that no RuntimeWarning was raised
@@ -104,7 +107,8 @@ def test_masked_image_filling_value_defaults():
104107
item.param.filling_value = np.nan
105108

106109
# This should handle the conversion gracefully
107-
with pytest.warns(None) as warning_list:
110+
with warnings.catch_warnings(record=True) as warning_list:
111+
warnings.simplefilter("always")
108112
item.update_mask()
109113

110114
# Check that no RuntimeWarning was raised

0 commit comments

Comments
 (0)