Skip to content

Commit 4586bba

Browse files
committed
Add a test for the abort with non-string candidates in calculate_suggestions.
1 parent 85bcb1b commit 4586bba

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Lib/test/test_traceback.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4072,6 +4072,17 @@ class A:
40724072
actual = self.get_suggestion(A(), 'bluch')
40734073
self.assertNotIn("blech", actual)
40744074

4075+
def test_suggestions_do_not_trigger_with_non_string_candidates(self):
4076+
class Parent:
4077+
def __dir__(self):
4078+
return [0, 'blech']
4079+
4080+
class WithNonStringAttrs(Parent):
4081+
blech = None
4082+
4083+
result = self.get_suggestion(WithNonStringAttrs(), "bluch")
4084+
self.assertNotIn("blech", result)
4085+
40754086
def test_getattr_suggestions_no_args(self):
40764087
class A:
40774088
blech = None

0 commit comments

Comments
 (0)