mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-139707: Better ModuleNotFoundError message for missing stdlib modules (GH-140219)
This commit is contained in:
parent
b2f9fb9db2
commit
47d2f68df2
3 changed files with 24 additions and 7 deletions
|
|
@ -5034,7 +5034,8 @@ def test_no_site_package_flavour(self):
|
|||
|
||||
self.assertIn(
|
||||
(b"Site initialization is disabled, did you forget to "
|
||||
b"add the site-packages directory to sys.path?"), stderr
|
||||
b"add the site-packages directory to sys.path "
|
||||
b"or to enable your virtual environment?"), stderr
|
||||
)
|
||||
|
||||
code = """
|
||||
|
|
@ -5046,9 +5047,20 @@ def test_no_site_package_flavour(self):
|
|||
|
||||
self.assertNotIn(
|
||||
(b"Site initialization is disabled, did you forget to "
|
||||
b"add the site-packages directory to sys.path?"), stderr
|
||||
b"add the site-packages directory to sys.path "
|
||||
b"or to enable your virtual environment?"), stderr
|
||||
)
|
||||
|
||||
def test_missing_stdlib_package(self):
|
||||
code = """
|
||||
import sys
|
||||
sys.stdlib_module_names |= {'spam'}
|
||||
import spam
|
||||
"""
|
||||
_, _, stderr = assert_python_failure('-S', '-c', code)
|
||||
|
||||
self.assertIn(b"Standard library module 'spam' was not found", stderr)
|
||||
|
||||
|
||||
class TestColorizedTraceback(unittest.TestCase):
|
||||
maxDiff = None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue