Closed
Copy link
Description
(Saving this for the upcoming sprints, ideally)
Let's remove the use of assert_raises
, assert_raise_message
, and assert_raises_regex
.
These should be replaced with the pytest context manager:
with pytest.raises(TheException, match="the expected message"):
function_call_here()
(no need for match
in the case of assert_raises
and assert_raise_message
I guess).
For contributors: pick one of the modules below, and please comment on this issue saying e.g. "I'm working on cluster/tests", to avoid other contributors choosing the same modules.
You can see all the occurrences of the entries that need to be removed with e.g. git grep "assert_raises" sklearn/ensemble/tests/
.
Modules that need cleaning
-
sklearn/cluster/tests/
Remove the use of assert_raises and assert_raises_regex from the tests #14649) -
sklearn/compose/tests/
MAINT:Fix assert raises insklearn/compose/tests/
#14670 -
sklearn/covariance/tests/
MNT:Remove the use of assert_raises and assert_raises_regex #14674 -
sklearn/datasets/tests/
MNT: datasets tests #14676 -
sklearn/decomposition/tests/
MAINT Remove the use of assert_raises* in decomposition #14679 -
sklearn/ensemble/tests/
TST replace assert_raise_* by pytest.raises in ensemble module #19399 -
sklearn/feature_extraction/tests/
MAINT:Fix assert raises insklearn/feature_extraction/tests/
#14694 -
sklearn/feature_selection/tests/
MAINT:Fix assert raises insklearn/feature_selection/tests/
#14697 -
sklearn/linear_model/tests/
TST replace assert_raise_* by pytest.raises in linear_model module #19399 #19440 -
sklearn/manifold/tests/
MAINT:Fix assert raises insklearn/manifold/tests/
#14699 -
sklearn/metrics/cluster/tests/
TST: Fix assert raises insklearn/metrics/cluster/tests/
#14707 -
sklearn/metrics/tests/
TST: Fix assert raises insklearn/metrics/tests/
#14715 -
sklearn/model_selection/tests/
TST replaces assert_raise* by pytest.raises in model_selection/tests/test_validation.py #19592 -
sklearn/neighbors/tests/
TST replace assert_raise_* by pytest.raises in neighbors module #19388 -
sklearn/neural_network/tests/
TST: Fix assert_raises in tests_neural_networks.py #14716 -
sklearn/preprocessing/tests/
MAINT:Fix assert raises insklearn/preprocessing/tests/
#14717 -
sklearn/semi_supervised/tests/
MAINT Fix assert raises in sklearn/semi_supervised/tests/ #14841 -
sklearn/svm/tests/
MAINT:Fix assert raises insklearn/svm/tests/
#14727 -
sklearn/tests/
TST replace assert_raise with pytest.raises in test_base.py #19500 -
sklearn/tree/tests/
MAINT:Fix assert raises insklearn/tree/tests/
#14737 -
sklearn/utils/estimator_checks.py
-
sklearn/utils/tests/
[MRG] CLN Remove the use of assert_raises in utils/ #16337
Some more:
-
see TST Change function names in metrics/cluster/tests/test_unsupervised.py #20065sklearn/metrics/cluster/tests/test_unsupervised.py
-
sklearn/compose/tests/test_column_transformer.py
-
sklearn/covariance/tests/test_robust_covariance.py
-
sklearn/datasets/tests/test_openml.py
-
sklearn/datasets/tests/test_samples_generator.py
-
sklearn/decomposition/tests/test_nmf.py
-
sklearn/decomposition/tests/test_factor_analysis.py
-
sklearn/feature_extraction/tests/test_text.py
-
sklearn/linear_model/tests/test_bayes.py
-
sklearn/linear_model/tests/test_sag.py
-
sklearn/linear_model/tests/test_ransac.py
-
sklearn/manifold/tests/test_locally_linear.py
-
sklearn/metrics/cluster/tests/test_unsupervised.py
-
sklearn/mixture/tests/test_bayesian_mixture.py
-
sklearn/mixture/tests/test_gaussian_mixture.py
-
sklearn/svm/tests/test_bounds.py
-
sklearn/svm/tests/test_sparse.py
-
sklearn/svm/tests/test_svm.py
-
sklearn/tests/test_base.py
-
sklearn/tests/test_isotonic.py
Also:
-
sklearn/utils/tests/test_estimator_checks.py
but this should use the customraises
CM insklearn/utils/_testing.py
instead, as we don't want to use pytest for this file
Metadata
Metadata
Assignees
Labels
No labels