Improve exception tests
See original GitHub issueMaybe we should change the way we test exceptions (see #476) to always use a context manger
as this way is easier to understand.
def test_it(self):
self.assertRaises(SomeException, do_something, 42, True)
def test_it_with_context(self):
with self.assertRaises(SomeException):
do_something(42, True)
Steps
- update old tests
- document this in the readme for new exercises
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:7 (7 by maintainers)
Top Results From Across the Web
How do you specify that an exception should be expected ...
I have a Boost unit test case which causes the object under test to throw an exception (that's the test, to cause an...
Read more >Exception correctness - 1.61.0 - Boost C++ Libraries
The Unit Test Framework provides several assertions for testing a code with respect to the exceptions correctness. The following assertions are available:.
Read more >Testing Exceptions: Harder Than It Looks - XP123
Exceptions are one of the most complicated constructs in many languages. We'll look at several ways to test them.
Read more >A Better Way to Test for Exceptions in Visual Studio
If you're testing for exceptions using ExpectedException, you have a better alternative.
Read more >3 Exception Practices To Improve Your Java Skills - Medium
You need to test and inspect an exception. You can use few ways to test exceptions. The solution depends on the JUnit version...
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
@cmccandless, wow, thanks a lot and sorry for the delay in review
As there is already a large amount of pull issues and pull requests designated for Hacktoberfest, I went ahead and created a single pull request for this (#945).