mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
gh-98254: Include stdlib module names in error messages for NameErrors (#98255)
This commit is contained in:
parent
3a639bbeac
commit
bb56dead33
6 changed files with 101 additions and 31 deletions
|
@ -3185,6 +3185,21 @@ class SuggestionFormattingTestBase:
|
|||
actual = self.get_suggestion(func)
|
||||
self.assertNotIn("something", actual)
|
||||
|
||||
def test_name_error_for_stdlib_modules(self):
|
||||
def func():
|
||||
stream = io.StringIO()
|
||||
|
||||
actual = self.get_suggestion(func)
|
||||
self.assertIn("forget to import 'io'", actual)
|
||||
|
||||
def test_name_error_for_private_stdlib_modules(self):
|
||||
def func():
|
||||
stream = _io.StringIO()
|
||||
|
||||
actual = self.get_suggestion(func)
|
||||
self.assertIn("forget to import '_io'", actual)
|
||||
|
||||
|
||||
|
||||
class PurePythonSuggestionFormattingTests(
|
||||
PurePythonExceptionFormattingMixin,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue