@@ -1338,16 +1338,43 @@ def blech(self):
1338
1338
self .assertEqual (obj , exc .obj )
1339
1339
1340
1340
def test_getattr_suggestions (self ):
1341
- class A :
1341
+ class Substitution :
1342
+ noise = more_noise = a = bc = None
1342
1343
blech = None
1343
1344
1344
- try :
1345
- A ().bluch
1346
- except AttributeError as exc :
1347
- with support .captured_stderr () as err :
1348
- sys .__excepthook__ (* sys .exc_info ())
1345
+ class Elimination :
1346
+ noise = more_noise = a = bc = None
1347
+ blch = None
1349
1348
1350
- self .assertIn ("blech" , err .getvalue ())
1349
+ class Addition :
1350
+ noise = more_noise = a = bc = None
1351
+ bluchin = None
1352
+
1353
+ class SubstitutionOverElimination :
1354
+ blach = None
1355
+ bluc = None
1356
+
1357
+ class SubstitutionOverAddition :
1358
+ blach = None
1359
+ bluchi = None
1360
+
1361
+ class EliminationOverAddition :
1362
+ blucha = None
1363
+ bluc = None
1364
+
1365
+ for cls , suggestion in [(Substitution , "blech?" ),
1366
+ (Elimination , "blch?" ),
1367
+ (Addition , "bluchin?" ),
1368
+ (EliminationOverAddition , "bluc?" ),
1369
+ (SubstitutionOverElimination , "blach?" ),
1370
+ (SubstitutionOverAddition , "blach?" )]:
1371
+ try :
1372
+ cls ().bluch
1373
+ except AttributeError as exc :
1374
+ with support .captured_stderr () as err :
1375
+ sys .__excepthook__ (* sys .exc_info ())
1376
+
1377
+ self .assertIn (suggestion , err .getvalue ())
1351
1378
1352
1379
def test_getattr_suggestions_do_not_trigger_for_long_attributes (self ):
1353
1380
class A :
0 commit comments