8000 gh-131936: Strengthen check in `_suggestions._generate_suggestions` by ZeroIntensity · Pull Request #131945 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-131936: Strengthen check in _suggestions._generate_suggestions #131945

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 31, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add a test.
  • Loading branch information
ZeroIntensity committed Mar 31, 2025
commit e5ca087305bc6d8c3ab15f1ea2a1bf65651055b2
26 changes: 25 additions & 1 deletion Lib/test/test_traceback.py
8000
Original file line number Diff line number Diff line change
Expand Up @@ -4619,7 +4619,31 @@ def test_levenshtein_distance_short_circuit(self):
@cpython_only
def test_suggestions_extension(self):
# Check that the C extension is available
import _suggestions # noqa: F401
import _suggestions

self.assertEqual(
_suggestions._generate_suggestions(
["hello", "world"],
"hell"
),
"hello"
)
self.assertEqual(
_suggestions._generate_suggestions(
["hovercraft"],
"eels"
),
None
)

# gh-131936: _generate_suggestions didn't check for exactly a list
class MyList(list):
pass

with self.assertRaises(TypeError):
_suggestions._generate_suggestions(MyList(), "")




class TestColorizedTraceback(unittest.TestCase):
Expand Down
Loading
0