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.

Why test with exception in test_import?

See original GitHub issue

I was checking for coverage and I saw this test

import alchemlyb 
 
def test_name(): 
    try: 
        assert alchemlyb.__name__ == 'alchemlyb' 
    except Exception as e: 
        raise e 

Why are we catching an Exception here in a test?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
DrDomenicoMarsoncommented, Sep 25, 2022

I didn’t know about “blame” 😃

It seems @ianmkenney did the commit 6 years ago! Could we just remove the try?

1reaction
DrDomenicoMarsoncommented, Sep 25, 2022

Great, I implemented the change in PR #240, I hope it’s fine, just not to have another PR just for that!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do you assert that a certain exception is thrown in JUnit ...
Using ExpectedException you can only test that one method throws an exception, because when that method is called, the test will stop executing...
Read more >
Asserting exceptions in JUnit - cassiomolin
This post explores some techniques for asserting exceptions in Java ... Test; import static org.hamcrest. ... Test; import org.junit.rules.
Read more >
JUnit - Expected Exceptions Test - Mkyong.com
In JUnit, there are 3 ways to test the expected exceptions : @Test , optional 'expected' attribute; Try-catch and always fail() ...
Read more >
JUnit Assert Exception - JUnit 5 and JUnit 4 - DigitalOcean
We can test expected exceptions using JUnit 5 assertThrows assertion. ... Test; import org.junit.rules.ExpectedException; public class ...
Read more >
JUnit Exception Testing - Memorynotfound
JUnit provides us with a basic toolkit to verify if an exception is thrown. There are some differences in how we can check...
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