Skip to content

Commit ba8ed5c

Browse files
committed
Add tests for warning suppression
1 parent d34446b commit ba8ed5c

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

tests/test_pixelmap.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,15 @@ def test_init_values():
3939
with pytest.raises(FrozenInstanceError, match="cannot assign to field 'values'"):
4040
pm.values = [[1]]
4141

42+
43+
def test_init_negative_values():
4244
with pytest.warns(UserWarning, match="PendelluftMap initialized with negative values"):
4345
_ = PendelluftMap([[0, -1], [-2, -3]])
46+
47+
with warnings.catch_warnings(record=True) as w:
48+
_ = PendelluftMap([[0, -1], [-2, -3]], suppress_negative_warning=True) # does not warn
49+
assert len(w) == 0
50+
4451
with warnings.catch_warnings(record=True) as w:
4552
_ = SignedPendelluftMap([[0, -1], [-2, -3]]) # does not warn
4653
assert len(w) == 0
@@ -229,6 +236,10 @@ def test_initialize_with_nan():
229236
with pytest.warns(UserWarning, match="PixelMap initialized with all NaN values."):
230237
_ = PixelMap([[np.nan, np.nan], [np.nan, np.nan]])
231238

239+
with warnings.catch_warnings(record=True) as w:
240+
_ = PixelMap([[np.nan, np.nan], [np.nan, np.nan]], suppress_all_nan_warning=True) # does not warn
241+
assert len(w) == 0
242+
232243

233244
def test_normalize_values_errors():
234245
pm = PixelMap(np.random.default_rng().random((10, 10), dtype=float))

0 commit comments

Comments
 (0)