Skip to content

Commit

Permalink
Merge pull request scikit-learn#2538 from ogrisel/test-test-common
Browse files Browse the repository at this point in the history
[MRG] Investigate test_common non-running on travis
  • Loading branch information
ogrisel committed Oct 21, 2013
2 parents 311172e + e24e391 commit ccad81c
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion sklearn/datasets/tests/test_20news.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_20news():

def test_20news_vectorized():
# This test is slow.
raise SkipTest
raise SkipTest("Test too slow.")

bunch = datasets.fetch_20newsgroups_vectorized(subset="train")
assert_true(sp.isspmatrix_csr(bunch.data))
Expand Down
2 changes: 1 addition & 1 deletion sklearn/datasets/tests/test_covtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_fetch():
data1 = fetch(shuffle=True, random_state=42)
except IOError as e:
if e.errno == errno.ENOENT:
raise SkipTest()
raise SkipTest("Covertype dataset can not be loaded.")

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

Expand Down
5 changes: 2 additions & 3 deletions sklearn/datasets/tests/test_lfw.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
def setup_module():
"""Test fixture run once and common to all tests of this module"""
if imsave is None:
raise SkipTest
raise SkipTest("PIL not installed.")

if not os.path.exists(LFW_HOME):
os.makedirs(LFW_HOME)
Expand All @@ -72,8 +72,7 @@ def setup_module():
try:
imsave(file_path, uniface)
except ImportError:
# PIL is not properly installed, skip those tests
raise SkipTest
raise SkipTest("PIL not installed")

# add some random file pollution to test robustness
with open(os.path.join(LFW_HOME, 'lfw_funneled', '.test.swp'), 'wb') as f:
Expand Down
2 changes: 1 addition & 1 deletion sklearn/decomposition/tests/test_dict_learning.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def test_dict_learning_online_initialization():

def test_dict_learning_online_partial_fit():
# this test was not actually passing before!
raise SkipTest
raise SkipTest("Online dict-learning test fails.")
n_components = 12
rng = np.random.RandomState(0)
V = rng.randn(n_components, n_features) # random init
Expand Down
2 changes: 1 addition & 1 deletion sklearn/decomposition/tests/test_sparse_pca.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def test_mini_batch_correct_shapes():


def test_mini_batch_fit_transform():
raise SkipTest
raise SkipTest("skipping mini_batch_fit_transform.")
alpha = 1
rng = np.random.RandomState(0)
Y, _, _ = generate_toy_data(3, 10, (8, 8), random_state=rng) # wide array
Expand Down
4 changes: 2 additions & 2 deletions sklearn/externals/joblib/test/test_parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def test_dispatch_multiprocessing():
lazily.
"""
if multiprocessing is None:
raise nose.SkipTest()
raise nose.SkipTest("No multiprocessing available.")
manager = multiprocessing.Manager()
queue = manager.list()

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

Expand Down
2 changes: 1 addition & 1 deletion sklearn/manifold/tests/test_spectral_embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def test_spectral_embedding_amg_solver(seed=36):
try:
from pyamg import smoothed_aggregation_solver
except ImportError:
raise SkipTest
raise SkipTest("pyagm not available.")

se_amg = SpectralEmbedding(n_components=2, affinity="nearest_neighbors",
eigen_solver="amg", n_neighbors=5,
Expand Down
3 changes: 1 addition & 2 deletions sklearn/neighbors/tests/test_ball_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,7 @@ def test_gaussian_kde(n_samples=1000):
try:
gkde = gaussian_kde(x_in, bw_method=h / np.std(x_in))
except TypeError:
# older versions of scipy don't accept explicit bandwidth
raise SkipTest
raise SkipTest("Old version of scipy, doesn't accept explicit bandwidth.")

dens_bt = bt.kernel_density(x_out[:, None], h) / n_samples
dens_gkde = gkde.evaluate(x_out)
Expand Down
3 changes: 1 addition & 2 deletions sklearn/neighbors/tests/test_kd_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ def test_gaussian_kde(n_samples=1000):
try:
gkde = gaussian_kde(x_in, bw_method=h / np.std(x_in))
except TypeError:
# older versions of scipy don't accept explicit bandwidth
raise SkipTest
raise SkipTest("Old scipy, does not accept explicit bandwidth.")

dens_kdt = kdt.kernel_density(x_out[:, None], h) / n_samples
dens_gkde = gkde.evaluate(x_out)
Expand Down
4 changes: 4 additions & 0 deletions sklearn/tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ def test_all_estimators():
estimators = all_estimators(include_meta_estimators=True)
classifier = LDA()

# Meta sanity-check to make sure that the estimator introspection runs
# properly
assert_greater(len(estimators), 0)

for name, Estimator in estimators:
# some can just not be sensibly default constructed
if name in dont_test:
Expand Down
6 changes: 5 additions & 1 deletion sklearn/utils/sparsetools/tests/test_traversal.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
csgraph_to_dense, csgraph_from_dense
except ImportError:
# Oldish versions of scipy don't have that
raise SkipTest
csgraph_from_dense = None


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


def test_graph_depth_first():
if csgraph_from_dense is None:
raise SkipTest("Old version of scipy, doesn't have csgraph.")
csgraph = np.array([[0, 1, 2, 0, 0],
[1, 0, 0, 0, 3],
[2, 0, 0, 7, 0],
Expand Down
2 changes: 1 addition & 1 deletion sklearn/utils/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,9 @@ def is_abstract(c):
path = sklearn.__path__
for importer, modname, ispkg in pkgutil.walk_packages(
path=path, prefix='sklearn.', onerror=lambda x: None):
module = __import__(modname, fromlist="dummy")
if ".tests." in modname:
continue
module = __import__(modname, fromlist="dummy")
classes = inspect.getmembers(module, inspect.isclass)
all_classes.extend(classes)

Expand Down

0 comments on commit ccad81c

Please sign in to comment.