Repository navigation
TST fix uncollected tests and avoidable warnings in the test suite - #35476
Merged
Merged
Conversation
- Fix `_mark_no_check_spmatrix_if_pytest_imported`, which returned the bare mark instead of the marked function. `test_check_estimator` and `test_check_estimator_clones` were therefore never collected. - Skip `SKIPPED_ESTIMATORS` in `_tested_estimators` instead of emitting a `SkipTestWarning` at collection time. - Pass `match=None` instead of `match=""` to `pytest.raises` in `check_warnings_as_errors` to avoid a `PytestWarning`. - Silence numpy's `PendingDeprecationWarning` when deliberately creating an `np.matrix` in `test_spectral_clustering_np_matrix_raises`.
cakedev0
approved these changes
Nov 24, 2026
Member
Author
results in 1460 failed, 39792 passed, 15168 skipped, 186 xfailed, 98 xpassed in 1424.85s (0:23:44) The good news is that with this PR we can see those warnings as errors if we want to. Examples |
virchan
approved these changes
Nov 25, 2026
virchan
left a comment
Member
There was a problem hiding this comment.
LGTM as well! Thanks everyone!
Merging.
This was referenced Nov 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reference Issues/PRs
Toward #5685.
What does this implement/fix? Explain your changes.
On main,
pytest -W erroremits avoidable warnings:_mark_no_check_spmatrix_if_pytest_importedintest_estimator_checks.pyreturned
pytest.mark.no_check_spmatrixinstead ofpytest.mark.no_check_spmatrix(f). As a consequence,test_check_estimatorand
test_check_estimator_cloneswere replaced by aMarkDecoratorandsilently not collected (introduced in Enable config setting
sparse_interfaceto control sparray and spmatrix creation #31177). Both tests are collectedagain and pass.
_tested_estimatorsnow skipsSKIPPED_ESTIMATORS(FrozenEstimator)directly instead of triggering a
SkipTestWarningwhile collectingtest_common.py. The set of collected tests is unchanged.check_warnings_as_errorspassedmatch=""topytest.raises, whichalways matches and emits a
PytestWarning. It now passesmatch=None.test_spectral_clustering_np_matrix_raisessilences numpy'sPendingDeprecationWarningaround the deliberatenp.matrixcreation.AI usage disclosure
I used AI assistance for:
I prompted the AI (Claude Fable 5.2) to fix
pytest -W errorand reviewed all changes.Any other comments?
One could argue that this closes #5685.
Details
`SKLEARN_WARNINGS_AS_ERRORS=1` (#28372) already turns `DeprecationWarning`, `FutureWarning` and `VisibleDeprecationWarning` into errors in CI, which is what the discussion in the issue converged on.A literal
pytest -W erroris a different goal. With this PR and-W "ignore::sklearn.exceptions.SkipTestWarning", a full local run (macOS,Python 3.13, numpy 2.4.2, scipy 1.17.0, pytest 9.0.2) gives 1466 failed,
39786 passed. Almost all failures are warnings that are emitted on purpose
for the inputs used in the tests:
UserWarningRuntimeWarning(353 are "invalid value encountered in cast")ConvergenceWarningUndefinedMetricWarningEfficiencyWarning/SparseEfficiencyWarningAbout 40% come from two parametrized tests,
test_set_output_transform_configuredandtest_classification_inf_nan_input. Making these pass would mean catchingexpected warnings in about 80 test files, and is better tracked in a new,
dedicated issue if we want it.
Notes
Not changed here, but noticed along the way:
NeighborsBaseraises aSyntaxWarningwhenpis given inmetric_params. The category is unusual, but it is asserted intest_metric_params_interfaceand in a DBSCAN test, so changing it is anAPI decision.
test_sklearn_warnings_as_errorscannot pass under a blanket-W errorby construction, since it checks that ignored warnings are recorded when
SKLEARN_WARNINGS_AS_ERRORSis unset.