-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
[MRG] CLN Remove the use of assert_raises in utils/ #16337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
+1
These are helpers, only used in the tests |
assert_raises(TypeError, incr_mean_variance_axis, X_lil, axis, | ||
last_mean, last_var, last_n) | ||
|
||
with pytest.raises(TypeError): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we ran this test twice on master ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, it could have been on purpose if the function was mutating an argument but that is not the case here :)
Please note that there still are some references to assert_raises and assert_raises_message in test_testing.py. They should be kept as long as these functions are used elsewhere |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @Batalex !
Although unfortunately we will have to revert changes in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, assuming CI passes. Thanks @Batalex !
thx @Batalex |
* CLN use pytest raises ctxt manager for class weights & estimators [skip ci] * CLN use pytest raises ctxt manager for multiclass test * CLN use pytest warns in estimator checks test * CLN use pytest raises ctxt manager for random test * CLN use pytest raises ctxt manager for sparsefuncs test * CLN use pytest raises ctxt manager for testing utils tests * CLN use pytest raises ctxt manager for utils tests * CLN use pytest raises ctxt manager for validation tests * revert test_estimator_check.py to upstream master
* CLN use pytest raises ctxt manager for class weights & estimators [skip ci] * CLN use pytest raises ctxt manager for multiclass test * CLN use pytest warns in estimator checks test * CLN use pytest raises ctxt manager for random test * CLN use pytest raises ctxt manager for sparsefuncs test * CLN use pytest raises ctxt manager for testing utils tests * CLN use pytest raises ctxt manager for utils tests * CLN use pytest raises ctxt manager for validation tests * revert test_estimator_check.py to upstream master
Reference Issues/PRs
Related to #14216
What does this implement/fix? Explain your changes.
Replace occurences of
assert_raises
&assert_raises_regex
in the following files:sklearn/utils/tests/test_estimator_checks.pyAny other comments?
assert_warns
withpytest.warns
context manager?assert_raises
is also used outside test files (namely,sklearn/utils/_testing.py
andsklearn/utils/estimator_checks.py
for simple checks. Is that normal? Does it not risk to produce errors with the python-O
flag?Edit: test_estimator_checks.py has been reverted to its prior state because it should run even without pytest.