mirror of
https://github.com/astral-sh/ruff.git
synced 2025-12-23 09:19:39 +00:00
Create per-rule pages and link from README (#2644)
This commit is contained in:
parent
f1cdd108e6
commit
271e4fda8c
17 changed files with 156 additions and 40 deletions
21
docs/rules/assert-raises-exception.md
Normal file
21
docs/rules/assert-raises-exception.md
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# assert-raises-exception (B017)
|
||||
|
||||
### What it does
|
||||
Checks for the use of `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).
|
||||
|
||||
Assert for a more specific exception (builtin or custom), use
|
||||
`assertRaisesRegex` or the context manager form of `assertRaises`.
|
||||
|
||||
### Example
|
||||
```python
|
||||
self.assertRaises(Exception, foo)
|
||||
```
|
||||
|
||||
Use instead:
|
||||
```python
|
||||
self.assertRaises(SomeSpecificException, foo)
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue