File tree 3 files changed +11
-2
lines changed
3 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -439,7 +439,8 @@ def check_for_b017(self, node):
439
439
item = node .items [0 ]
440
440
item_context = item .context_expr
441
441
if (
442
- hasattr (item_context .func , "attr" )
442
+ hasattr (item_context , "func" )
443
+ and hasattr (item_context .func , "attr" ) # noqa W503
443
444
and item_context .func .attr == "assertRaises" # noqa W503
444
445
and len (item_context .args ) == 1 # noqa W503
445
446
and item_context .args [0 ].id == "Exception" # noqa W503
Original file line number Diff line number Diff line change 5
5
import unittest
6
6
7
7
8
+ CONSTANT = True
9
+
10
+
11
+ def something_else () -> None :
12
+ for i in (1 , 2 , 3 ):
13
+ print (i )
14
+
15
+
8
16
class Foobar (unittest .TestCase ):
9
17
def evil_raises (self ) -> None :
10
18
with self .assertRaises (Exception ):
Original file line number Diff line number Diff line change @@ -210,7 +210,7 @@ def test_b017(self):
210
210
filename = Path (__file__ ).absolute ().parent / "b017.py"
211
211
bbc = BugBearChecker (filename = str (filename ))
212
212
errors = list (bbc .run ())
213
- expected = self .errors (B017 (10 , 8 ))
213
+ expected = self .errors (B017 (18 , 8 ))
214
214
self .assertEqual (errors , expected )
215
215
216
216
def test_b301_b302_b305 (self ):
You can’t perform that action at this time.
0 commit comments