Skip to content

Commit 595137c

Browse files
committed
test_jaccard_distance_numpy: Check for warning instead of printing it
1 parent 9a778e4 commit 595137c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Orange/tests/test_distances.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
from unittest import TestCase
55
from unittest.mock import patch
66
import pickle
7+
from unittest.mock import patch
78

89
import numpy as np
910
import scipy
1011
import scipy.spatial
1112
import scipy.stats
1213
from scipy.sparse import csr_matrix
14+
from sklearn.exceptions import DataConversionWarning
1315

1416
from Orange.data import (Table, Domain, ContinuousVariable,
1517
DiscreteVariable, StringVariable, Instance)
@@ -499,10 +501,13 @@ def test_jaccard_distance_many_examples(self):
499501
np.array([[0., 0., 0.5],
500502
[0., 0., 0.5]]))
501503

502-
def test_jaccard_distance_numpy(self):
504+
@patch("warnings.warn")
505+
def test_jaccard_distance_numpy(self, warn):
503506
np.testing.assert_almost_equal(
504507
self.dist(self.titanic[0].x, self.titanic[2].x, axis=1),
505508
np.array([[0.5]]))
509+
self.assertIs(warn.call_args[0][1], DataConversionWarning)
510+
warn.assert_called()
506511
np.testing.assert_almost_equal(
507512
self.dist(self.titanic.X),
508513
np.array([[0., 0., 0.5, 0.5],

0 commit comments

Comments
 (0)