This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2016年09月13日 20:12 by facundobatista, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Messages (3) | |||
|---|---|---|---|
| msg276334 - (view) | Author: Facundo Batista (facundobatista) * (Python committer) | Date: 2016年09月13日 20:12 | |
So, you could do: exc = self.assertRaises(ValueError, somefunc, someargs) And then, explore "exc" as will. Yes, you can get the exception if you use assertRaises as a context manager, but that leads to more cumbersome code: with self.assertRaises(ValueError) as cm: somefunc(someargs) exc = cm.exception |
|||
| msg276454 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2016年09月14日 14:13 | |
-0 This doesn't feel Pythonic to me. |
|||
| msg276458 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2016年09月14日 14:44 | |
This has been proposed and rejected several times before. IMO, a strong reason to reject it is that no other assert methods return values. Consistency is important. Also note that cm survives the context manager, so you don't need that assignment statement. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:36 | admin | set | github: 72322 |
| 2018年01月03日 16:11:31 | r.david.murray | link | issue32487 superseder |
| 2016年09月14日 14:44:34 | r.david.murray | set | status: open -> closed superseder: unittest.assertRaises() return the raised exception nosy: + r.david.murray messages: + msg276458 resolution: duplicate stage: resolved |
| 2016年09月14日 14:13:58 | rhettinger | set | nosy:
+ rhettinger messages: + msg276454 |
| 2016年09月13日 20:12:11 | facundobatista | create | |