Skip to content

Commit 7be2b78

Browse files
committed
Add more tests
1 parent ff8fc2a commit 7be2b78

File tree

1 file changed

+34
-7
lines changed

1 file changed

+34
-7
lines changed

Lib/test/test_exceptions.py

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,16 +1338,43 @@ def blech(self):
13381338
self.assertEqual(obj, exc.obj)
13391339

13401340
def test_getattr_suggestions(self):
1341-
class A:
1341+
class Substitution:
1342+
noise = more_noise = a = bc = None
13421343
blech = None
13431344

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
13491348

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())
13511378

13521379
def test_getattr_suggestions_do_not_trigger_for_long_attributes(self):
13531380
class A:

0 commit comments

Comments
 (0)