Message266820
Yes. What does such an assertion actually mean?
Why would I write `self.assertNotRaises(ValueError, spam, arg)` rather than just call `spam(arg)`? The only difference is that assertNotRaises will treat one specific exception as a test failure rather than a error, but I don't think that's useful. spam(arg) presumably is supposed to return something, or do something, not merely "don't raise ValueError". Raising ValueError should be no different from raising any other exception: it's a error, not a failure.
It makes sense to test for expected exceptions. I don't think it makes sense to test for exceptions that don't happen. Every single successful test of `spam(arg)` shows that ValueError is not raised, as well as every imaginable other exception. I don't think there is any need for an assert method to test for exceptions not being raised. |
|
Date |
User |
Action |
Args |
2016-06-01 15:10:28 | steven.daprano | set | recipients:
+ steven.daprano, rbcollins, ezio.melotti, michael.foord, bar.harel |
2016-06-01 15:10:28 | steven.daprano | set | messageid: <1464793828.48.0.580584013214.issue27176@psf.upfronthosting.co.za> |
2016-06-01 15:10:28 | steven.daprano | link | issue27176 messages |
2016-06-01 15:10:28 | steven.daprano | create | |
|