Remove the use of assert_warns and assert_warns_message from the tests
See original GitHub issue(Saving this for the upcoming sprints, ideally)
Let’s remove the use of assert_warns
, assert_warns_message
These should be replaced with the pytest context manager:
https://doc.pytest.org/en/reorganize-docs/recwarn.html
with pytest.warns(TheWarning, match="the expected message"):
function_call_here()
For contributors: pick one of the modules, 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_warns” sklearn/ensemble/tests/.
Issue Analytics
- State:
- Created 3 years ago
- Comments:25 (23 by maintainers)
Top Results From Across the Web
unittest — Unit testing framework — Python 3.11.1 ...
It checks for a specific response to a particular set of inputs. unittest provides a base class, TestCase , which may be used...
Read more >How to test with Python's unittest that a warning has been ...
Starting with Python 3.2, you can simply use assertWarns() method. with self.assertWarns(Warning): do_something().
Read more >Coding style — Django 2.1rc1 documentation
In tests, use assertRaisesMessage() and assertWarnsMessage() instead of assertRaises() and assertWarns() so you can check the exception or warning message.
Read more >26.4. unittest — Unit testing framework — Python 3.6.3 ...
The unittest module can be used from the command line to run tests from modules, ... When used as a context manager, assertWarns()...
Read more >django/test/testcases.py - Fossies
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Working on
decomposition/tests
This is the end of this issue! Thank you everybody involved!