diff options
| author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2022-10-15 22:13:33 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-15 22:13:33 (GMT) |
| commit | bb56dead336357153a0c3b8cc9d9d6856d2c5a03 (patch) | |
| tree | b3e336da20cd08a82d86f19c054f8c780ee422da /Lib/test/test_traceback.py | |
| parent | 3a639bbeace73d54f7e5431d3224c8c8223d81ae (diff) | |
| download | cpython-bb56dead336357153a0c3b8cc9d9d6856d2c5a03.zip cpython-bb56dead336357153a0c3b8cc9d9d6856d2c5a03.tar.gz cpython-bb56dead336357153a0c3b8cc9d9d6856d2c5a03.tar.bz2 | |
gh-98254: Include stdlib module names in error messages for NameErrors (#98255)
Diffstat (limited to 'Lib/test/test_traceback.py')
| -rw-r--r-- | Lib/test/test_traceback.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py index 4864b5c..2d17e06 100644 --- a/Lib/test/test_traceback.py +++ b/Lib/test/test_traceback.py @@ -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, |
