question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 3 years ago
  • Comments:25 (23 by maintainers)

github_iconTop GitHub Comments

1reaction
nanshanlicommented, Jun 6, 2021

Working on decomposition/tests

0reactions
ogriselcommented, Jul 13, 2021

This is the end of this issue! Thank you everybody involved!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found