---
source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs
---
B017.py:23:14: B017 `assertRaises(Exception)` should be considered evil
   |
21 | class Foobar(unittest.TestCase):
22 |     def evil_raises(self) -> None:
23 |         with self.assertRaises(Exception):
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B017
24 |             raise Exception("Evil I say!")
   |

B017.py:27:14: B017 `assertRaises(BaseException)` should be considered evil
   |
26 |     def also_evil_raises(self) -> None:
27 |         with self.assertRaises(BaseException):
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B017
28 |             raise Exception("Evil I say!")
   |

B017.py:45:10: B017 `pytest.raises(Exception)` should be considered evil
   |
44 | def test_pytest_raises():
45 |     with pytest.raises(Exception):
   |          ^^^^^^^^^^^^^^^^^^^^^^^^ B017
46 |         raise ValueError("Hello")
   |

B017.py:48:10: B017 `pytest.raises(Exception)` should be considered evil
   |
46 |         raise ValueError("Hello")
47 | 
48 |     with pytest.raises(Exception), pytest.raises(ValueError):
   |          ^^^^^^^^^^^^^^^^^^^^^^^^ B017
49 |         raise ValueError("Hello")
   |


