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 2010年09月03日 10:50 by pitrou, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
Files | ||||
---|---|---|---|---|
File name | Uploaded | Description | Edit | |
assertwarns.patch | pitrou, 2010年09月03日 14:13 | |||
assertwarns2.patch | pitrou, 2010年09月04日 20:33 |
Messages (14) | |||
---|---|---|---|
msg115434 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2010年09月03日 10:50 | |
Similar to assertRaises and assertRaisesRegexp, unittest should provide assertWarns and assertWarnsRegexp, to check that a given callable (or piece of code) triggers a particular warning. Currently, you have to do that manually using a mixture of warnings.catch_warnings and warnings.filterwarnings, which is pretty annoying. |
|||
msg115436 - (view) | Author: Michael Foord (michael.foord) * (Python committer) | Date: 2010年09月03日 11:04 | |
+1 |
|||
msg115449 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2010年09月03日 12:44 | |
The __warningregistry__ stuff looks horrible. |
|||
msg115450 - (view) | Author: Florent Xicluna (flox) * (Python committer) | Date: 2010年09月03日 12:51 | |
> unittest should provide assertWarns and assertWarnsRegexp +1 (the internal helpers in test.support could be refactored) > The __warningregistry__ stuff looks horrible. +1 (and it does not behave exactly the same in all Python versions) |
|||
msg115451 - (view) | Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) | Date: 2010年09月03日 12:55 | |
+1 from me as well. |
|||
msg115453 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2010年09月03日 13:59 | |
Here is a patch. The approach is different from support.check_warnings(), and tries to mimic assertRaises* instead. |
|||
msg115455 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2010年09月03日 14:13 | |
There was some dead code in the patch. |
|||
msg115460 - (view) | Author: Michael Foord (michael.foord) * (Python committer) | Date: 2010年09月03日 15:19 | |
(Note that in general I am against extending the TestCase API with more asserts given how wide it is and how much it has expanded in recent versions. I've written warning checking code enough times for third party projects that I think this is worth it though.) |
|||
msg115465 - (view) | Author: Florent Xicluna (flox) * (Python committer) | Date: 2010年09月03日 16:45 | |
Patch looks good. However tests do not pass with -Werror (while test_warnings and others pass). Is there a way to catch multiple warnings on a single logical line? (With assertRaises we don't have such use case) |
|||
msg115469 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2010年09月03日 17:05 | |
> Patch looks good. However tests do not pass with -Werror (while test_warnings and others pass). > > > Is there a way to catch multiple warnings on a single logical line? I thought we could beef up the API with additional arguments. That would be at the expense of removing the "callable" argument (and mandating the use as a context manager), though, otherwise the signature gets too complicated. |
|||
msg115470 - (view) | Author: Michael Foord (michael.foord) * (Python committer) | Date: 2010年09月03日 17:08 | |
Why not accepting a tuple of warnings? That doesn't make sense for assertWarnsRegexp of course. |
|||
msg115471 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2010年09月03日 17:12 | |
> Why not accepting a tuple of warnings? It already does (and there's a test!). > That doesn't make sense for assertWarnsRegexp of course. True. |
|||
msg115614 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2010年09月04日 20:33 | |
Updated patch so that the tests pass with -Werror. Do you think this should be committed before the next alpha? |
|||
msg115730 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2010年09月06日 19:26 | |
Committed in r84563! |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022年04月11日 14:57:06 | admin | set | github: 53963 |
2010年11月01日 15:00:13 | ezio.melotti | set | nosy:
+ ezio.melotti |
2010年09月06日 19:26:14 | pitrou | set | status: open -> closed resolution: fixed messages: + msg115730 stage: patch review -> resolved |
2010年09月04日 20:33:53 | pitrou | set | files:
+ assertwarns2.patch messages: + msg115614 |
2010年09月03日 23:06:39 | flox | link | issue8273 dependencies |
2010年09月03日 17:12:58 | pitrou | set | messages: + msg115471 |
2010年09月03日 17:08:35 | michael.foord | set | messages: + msg115470 |
2010年09月03日 17:05:04 | pitrou | set | messages: + msg115469 |
2010年09月03日 16:45:57 | flox | set | messages:
+ msg115465 stage: needs patch -> patch review |
2010年09月03日 15:19:42 | michael.foord | set | messages: + msg115460 |
2010年09月03日 14:13:13 | pitrou | set | files: - assertwarns.patch |
2010年09月03日 14:13:08 | pitrou | set | files:
+ assertwarns.patch messages: + msg115455 |
2010年09月03日 13:59:45 | pitrou | set | files:
+ assertwarns.patch keywords: + patch messages: + msg115453 |
2010年09月03日 12:55:19 | giampaolo.rodola | set | nosy:
+ giampaolo.rodola messages: + msg115451 |
2010年09月03日 12:51:05 | flox | set | nosy:
+ flox messages: + msg115450 |
2010年09月03日 12:44:54 | pitrou | set | messages: + msg115449 |
2010年09月03日 11:04:15 | michael.foord | set | messages: + msg115436 |
2010年09月03日 10:50:15 | pitrou | create |