-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
ruleImplementing or modifying a lint ruleImplementing or modifying a lint rule
Description
Summary
I found this while working on #18972
assert-raises-exception (B017) does not lint on non-with calls, even though both unittest and pytest support them:
https://play.ruff.rs/c875da29-d677-4f97-ad23-2efd2fa88231
import unittest
def func_that_will_raise():
raise ValueError
class Tests(unittest.TestCase):
def test_raises(self):
with self.assertRaises(Exception): # B017
func_that_will_raise()
self.assertRaises(Exception, func_that_will_raise) # No error
import pytest
def test_raises():
with pytest.raises(Exception): # B017
func_that_will_raise()
pytest.raises(Exception, func_that_will_raise) # No errorunittest docs on assertRaises
pytest docs on alternate raises form
Version
playground
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
ruleImplementing or modifying a lint ruleImplementing or modifying a lint rule