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 2017年03月07日 12:51 by viniciusd, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 551 | closed | viniciusd, 2017年03月07日 15:47 | |
| Messages (3) | |||
|---|---|---|---|
| msg289161 - (view) | Author: Vinícius Dantas (viniciusd) * | Date: 2017年03月07日 12:51 | |
Unittest provides us some assert methods, yet one is missing: the assertDoesNotRaise context. When running tests, tests may end up as failures, successes or errors. It's worth noting that errors and failures are conceptually different, and that's the point on having an assertDoesNotRaise context, alike the assertRaises context. This context would be useful, for example, when using Selenium client, it would be helpful to know if an alert popped, given there is no method to check if there is an alert, we'd use a code like: with assertDoesNotRaise(NoAlertPresentException): driver.switch_to.alert.text It is also important to mention that it makes explicit what we are testing. After all, explicit is better than implicit. |
|||
| msg289164 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2017年03月07日 14:13 | |
This has already been discussed and rejected (issue 14403). In practice the distinction between a failure and an error is not useful, and a comment in the test is IMO clearer than a no-op context manager: you can use a positive sentence instead of the reader having to understand a double negative ("Make sure there is an alert present; this will raise if not.") The fact that there is no method to check that there is an alert sounds like a missing feature somewhere outside of Python? Finally, if having this would in your group's opinion make your test code better, you can add it to your own TestCase subclass. But our conclusion was that it doesn't belong in the stdlib. |
|||
| msg289233 - (view) | Author: Vinícius Dantas (viniciusd) * | Date: 2017年03月08日 12:39 | |
As a last argument: It is a matter of coherence/consistency with unittest's API, given that this module does differentiates errors from failures |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:43 | admin | set | github: 73933 |
| 2017年03月08日 12:39:31 | viniciusd | set | messages: + msg289233 |
| 2017年03月07日 15:47:18 | viniciusd | set | pull_requests: + pull_request453 |
| 2017年03月07日 14:13:14 | r.david.murray | set | status: open -> closed superseder: unittest module: provide inverse of "assertRaises" nosy: + r.david.murray messages: + msg289164 resolution: duplicate stage: resolved |
| 2017年03月07日 12:51:31 | viniciusd | create | |