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.

Improve exception tests

See original GitHub issue

Maybe 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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
ilya-khadykincommented, Oct 17, 2017

@cmccandless, wow, thanks a lot and sorry for the delay in review

1reaction
cmccandlesscommented, Oct 17, 2017

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).

Read more comments on GitHub >

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

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