TST replace pytest.warns(None) in metrics/tests/test_pairwise.py
+import warnings
from types import GeneratorType
import numpy as np
@@ -192,18 +193,18 @@ def test_pairwise_boolean_distance(metric):
pairwise_distances(X.astype(bool), Y=Y, metric=metric)
# Check that no warning is raised if X is already boolean and Y is None:
- with pytest.warns(None) as records:
+ with warnings.catch_warnings():
+ warnings.simplefilter("error", DataConversionWarning)
pairwise_distances(X.astype(bool), metric=metric)
- assert not [w.message for w in records]
def test_no_data_conversion_warning():
# No warnings issued if metric is not a boolean distance function
rng = np.random.RandomState(0)
X = rng.randn(5, 4)
- with pytest.warns(None) as records:
+ with warnings.catch_warnings():
+ warnings.simplefilter("error", DataConversionWarning)
pairwise_distances(X, metric="minkowski")
- assert not [w.message for w in records]
@pytest.mark.parametrize("func", [pairwise_distances, pairwise_kernels])
