10000 Merge pull request #2538 from ogrisel/test-test-common · Felixhawk/scikit-learn@ccad81c · GitHub
[go: up one dir, main page]

Skip to content

Commit ccad81c

Browse files
committed
Merge pull request scikit-learn#2538 from ogrisel/test-test-common
[MRG] Investigate test_common non-running on travis
2 parents 311172e + e24e391 commit ccad81c

File tree

12 files changed

+21
-16
lines changed

12 files changed

+21
-16
lines changed

sklearn/datasets/tests/test_20news.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def test_20news():
4141

4242
def test_20news_vectorized():
4343
# This test is slow.
44-
raise SkipTest
44+
raise SkipTest("Test too slow.")
4545

4646
bunch = datasets.fetch_20newsgroups_vectorized(subset="train")
4747
assert_true(sp.isspmatrix_csr(bunch.data))

sklearn/datasets/tests/test_covtype.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def test_fetch():
1717
data1 = fetch(shuffle=True, random_state=42)
1818
except IOError as e:
1919
if e.errno == errno.ENOENT:
20-
raise SkipTest()
20+
raise SkipTest("Covertype dataset can not be loaded.")
2121

2222
data2 = fetch(shuffle=True, random_state=37)
2323

sklearn/datasets/tests/test_lfw.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
def setup_module():
5050
"""Test fixture run once and common to all tests of this module"""
5151
if imsave is None:
52-
raise SkipTest
52+
raise SkipTest("PIL not installed.")
5353

5454
if not os.path.exists(LFW_HOME):
5555
os.makedirs(LFW_HOME)
@@ -72,8 +72,7 @@ def setup_module():
7272
try:
7373
imsave(file_path, uniface)
7474
except ImportError:
75-
# PIL is not properly installed, skip those tests
76-
raise SkipTest
75+
raise SkipTest("PIL not installed")
7776

7877
# add some random file pollution to test robustness
7978
with open(os.path.join(LFW_HOME, 'lfw_funneled', '.test.swp'), 'wb') as f:

sklearn/decomposition/tests/test_dict_learning.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def test_dict_learning_online_initialization():
133133

134134
def test_dict_learning_online_partial_fit():
135135
# this test was not actually passing before!
136-
raise SkipTest
136+
raise SkipTest("Online dict-learning test fails.")
137137
n_components = 12
138138
rng = np.random.RandomState(0)
139139
V = rng.randn(n_components, n_features) # random init

sklearn/decomposition/tests/test_sparse_pca.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def test_mini_batch_correct_shapes():
135135

136136

137137
def test_mini_batch_fit_transform():
138-
raise SkipTest
138+
raise SkipTest("skipping mini_batch_fit_transform.")
139139
alpha = 1
140140
rng = np.random.RandomState(0)
141141
Y, _, _ = generate_toy_data(3, 10, (8, 8), random_state=rng) # wide array

sklearn/externals/joblib/test/test_parallel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def test_dispatch_multiprocessing():
211211
lazily.
212212
"""
213213
if multiprocessing is None:
214-
raise nose.SkipTest()
214+
raise nose.SkipTest("No multiprocessing available.")
215215
manager = multiprocessing.Manager()
216216
queue = 341A manager.list()
217217

@@ -253,7 +253,7 @@ def test_multiple_spawning():
253253
# subprocesses will raise an error, to avoid infinite loops on
254254
# systems that do not support fork
255255
if not int(os.environ.get('JOBLIB_MULTIPROCESSING', 1)):
256-
raise nose.SkipTest()
256+
raise nose.SkipTest("No multiprocessing available.")
257257
nose.tools.assert_raises(ImportError, Parallel(n_jobs=2),
258258
[delayed(_reload_joblib)() for i in range(10)])
259259

sklearn/manifold/tests/test_spectral_embedding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def test_spectral_embedding_amg_solver(seed=36):
120120
try:
121121
from pyamg import smoothed_aggregation_solver
122122
except ImportError:
123-
raise SkipTest
123+
raise SkipTest("pyagm not available.")
124124

125125
se_amg = SpectralEmbedding(n_components=2, affinity="nearest_neighbors",
126126
eigen_solver="amg", n_neighbors=5,

sklearn/neighbors/tests/test_ball_tree.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@ def test_gaussian_kde(n_samples=1000):
188188
try:
189189
gkde = gaussian_kde(x_in, bw_method=h / np.std(x_in))
190190
except TypeError:
191-
# older versions of scipy don't accept explicit bandwidth
192-
raise SkipTest
191+
raise SkipTest("Old version of scipy, doesn't accept explicit bandwidth.")
193192

194193
dens_bt = bt.kernel_density(x_out[:, None], h) / n_samples
195194
dens_gkde = gkde.evaluate(x_out)

sklearn/neighbors/tests/test_kd_tree.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ def test_gaussian_kde(n_samples=1000):
144144
try:
145145
gkde = gaussian_kde(x_in, bw_method=h / np.std(x_in))
146146
except TypeError:
147-
# older versions of scipy don't accept explicit bandwidth
148-
raise SkipTest
147+
raise SkipTest("Old scipy, does not accept explicit bandwidth.")
149148

150149
dens_kdt = kdt.kernel_density(x_out[:, None], h) / n_samples
151150
dens_gkde = gkde.evaluate(x_out)

sklearn/tests/test_common.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ def test_all_estimators():
5858
estimators = all_estimators(include_meta_estimators=True)
5959
classifier = LDA()
6060

61+
# Meta sanity-check to make sure that the estimator introspection runs
62+
# properly
63+
assert_greater(len(estimators), 0)
64+
6165
for name, Estimator in estimators:
6266
# some can just not be sensibly default constructed
6367
if name in dont_test:

sklearn/utils/sparsetools/tests/test_traversal.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
csgraph_to_dense, csgraph_from_dense
1010
except ImportError:
1111
# Oldish versions of scipy don't have that
12-
raise SkipTest
12+
csgraph_from_dense = None
1313

1414

1515
def test_graph_breadth_first():
16+
if csgraph_from_dense is None:
17+
raise SkipTest("Old version of scipy, doesn't have csgraph.")
1618
csgraph = np.array([[0, 1, 2, 0, 0],
1719
[1, 0, 0, 0, 3],
1820
[2, 0, 0, 7, 0],
@@ -33,6 +35,8 @@ def test_graph_breadth_first():
3335

3436

3537
def test_graph_depth_first():
38+
if csgraph_from_dense is None:
39+
raise SkipTest("Old version of scipy, doesn't have csgraph.")
3640
csgraph = np.array([[0, 1, 2, 0, 0],
3741
[1, 0, 0, 0, 3],
3842
[2, 0, 0, 7, 0],

sklearn/utils/testing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,9 @@ def is_abstract(c):
297297
path = sklearn.__path__
298298
for importer, modname, ispkg in pkgutil.walk_packages(
299299
path=path, prefix='sklearn.', onerror=lambda x: None):
300-
module = __import__(modname, fromlist="dummy")
301300
if ".tests." in modname:
302301
continue
302+
module = __import__(modname, fromlist="dummy")
303303
classes = inspect.getmembers(module, inspect.isclass)
304304
all_classes.extend(classes)
305305

0 commit comments

Comments
 (0)
0