mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:24 +00:00
Tweak format for rule explanations (#2645)
This commit is contained in:
parent
4b49fd9494
commit
56398e0002
3 changed files with 50 additions and 31 deletions
|
@ -1,13 +1,13 @@
|
|||
# assert-raises-exception (B017)
|
||||
|
||||
Derived from the **flake8-bugbear** linter.
|
||||
### What it does
|
||||
Checks for the use of `assertRaises(Exception)`.
|
||||
Checks for `self.assertRaises(Exception)`.
|
||||
|
||||
### Why is this bad?
|
||||
`assertRaises(Exception)` can lead to your test passing even if the
|
||||
code being tested is never executed (e.g., due to a typo).
|
||||
code being tested is never executed due to a typo.
|
||||
|
||||
Assert for a more specific exception (builtin or custom), use
|
||||
Either assert for a more specific exception (builtin or custom), use
|
||||
`assertRaisesRegex` or the context manager form of `assertRaises`.
|
||||
|
||||
### Example
|
||||
|
@ -18,4 +18,4 @@ self.assertRaises(Exception, foo)
|
|||
Use instead:
|
||||
```python
|
||||
self.assertRaises(SomeSpecificException, foo)
|
||||
```
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue